Checking the size of an object in Objective-C

All the compiler knows about is the pointer, which is why you’re getting the size of the pointer back. To see the size of the allocated object, use one of the following code snippets: With ARC: #import <malloc/malloc.h> // … NSLog(@”Size of %@: %zd”, NSStringFromClass([myObject class]), malloc_size((__bridge const void *) myObject)); Without ARC: #import <malloc/malloc.h> … Read more

Sizeof struct in Go

Roger already showed how to use SizeOf method from the unsafe package. Make sure you read this before relying on the value returned by the function: The size does not include any memory possibly referenced by x. For instance, if x is a slice, Sizeof returns the size of the slice descriptor, not the size … Read more

Does sizeof(T) == sizeof(const T) and alignof(T) == alignof(const T)

Section 3.9.3: The cv-qualified or cv-unqualified versions of a type are distinct types; however, they shall have the same representation and alignment requirements (3.11). 53 “cv-qualified” here refers to const and volatile. So the answer is, yes. const and volatile only specify the limitations/attributes of access to the specified object. They are not considered to … Read more

Why the sizeof(bool) is not defined to be one, by the Standard itself?

The other likely size for it is that of int, being the “efficient” integer type for the platform. On architectures where it makes any difference whether the implementation chooses 1 or sizeof(int) there could be a trade-off between size (but if you’re happy to waste 7 bits per bool, why shouldn’t you be happy to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)