4 ms·
The compiler doesn't care much how your structure element is named. The naming scheme is for the benefit of the developer. Once the program is compiled the vari
by wila 12y ago
The compiler doesn't care much how your structure element is named. The naming scheme is for the benefit of the developer. Once the program is compiled the variable is referenced by memory address, not variable name. Sorting them by name would not help there.
- dlp211 12y agoI don't think (s)he meant sorted alphabetically, but rather, sorted in such a way as to minimize memory usage, ie: packed. This is obviously not the default in C, but can be enabled via compiler extensions. It's also important that the compiler doesn't automatically do this since structs of the same type can be of different sizes. In order for this to work, the memory layout needs to be as originally defined in order to be correct. For an example of this see the simple dynamic string library used in redis.