Thanks for reporting. I tested it with current trunk and older gcc
(4.9, 4.8), and things look pretty similar. So this isn't actually a
regression, but it is a missing feature for gcc. So you might want to
report this missing feature to gcc's bz for discussion.
[bugs:#500] #pragma pack(push,n) does not work when n is a macro
Status: open
Group: v1.0 (example)
Created: Thu Oct 08, 2015 02:45 PM UTC by vitaly_s
Last Updated: Thu Oct 08, 2015 02:45 PM UTC
Owner: nobody
Attachments:
b.c (843 Bytes; text/plain)
GCC 5.2.0.
pragma pack(push,n) does not work when n is a macro
Example code produces:
sizeof(struct A) = 16
sizeof(struct B) = 12
sizeof(struct C) = 16
while sizeof(struct C) must be 12.
Also, #pragma pack(n) does not work with macro. See example in file b.c.
Thanks for answer. After I have found it, I didn’t test it with previous releases. It is good to have this information now.
So, to conclude... While my own code can use something like this
#pragma pack(push)
#if defined(_WIN64)
#pragma pack(8)
#elif defined(_WIN32)
#pragma pack(4)
#else
#error Win32 and Win64 targets are currently supported
#endif
...
#pragma pack(pop)
although it would be better to use simple '#pragma pack(push, _PLATFORM_PACKING)' the bug still has much more consequences. Almost every include file supplied with GCC also has '#pragma pack(push,_CRT_PACKING)' directive. Thus, it is certainly a bug, not a 'missing feature', because GCC itself heavily relies on it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for reporting. I tested it with current trunk and older gcc
(4.9, 4.8), and things look pretty similar. So this isn't actually a
regression, but it is a missing feature for gcc. So you might want to
report this missing feature to gcc's bz for discussion.
Thanks,
Kai
2015-10-08 16:45 GMT+02:00 vitaly_s vitalysxii@users.sf.net:
Related
Bugs: #500
Thanks for answer. After I have found it, I didn’t test it with previous releases. It is good to have this information now.
So, to conclude... While my own code can use something like this
although it would be better to use simple '#pragma pack(push, _PLATFORM_PACKING)' the bug still has much more consequences. Almost every include file supplied with GCC also has '#pragma pack(push,_CRT_PACKING)' directive. Thus, it is certainly a bug, not a 'missing feature', because GCC itself heavily relies on it.