Friday 6 December 2019

c - Is `sizeof(char*)` always equal to `sizeof(double*)`?

Both, sizeof(char*) and sizeof(double*) are the size of a pointer. So they are very likely identical on any imaginable system.


It is however theoretically possible that an implementation has different methods for referencing different datatypes. I could imagine a system wiht a small size optimisation memory scheme doing e.g. single byte plain old data in a special place with implicitly "only" 32 bit pointers, while it does larger compound constructs in a larger area, which needs 64 bit pointers.
So there is no guarantee of this seemingly "obvious" assumption.


This does of course assume that everything is on the same system, pointer sizes can and do vary between different systems.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...