Paul Mensonides wrote:
Edward Diener wrote:
Will a compiler correctly pick up the #pragma as a preprocessor line or is the preprocessor stage finished once the macro is fully expanded ? I believe the latter is true, although I could be wrong.
It is not technically legal, but it might work anyway, as #pragmas usually aren't picked up by the preprocessor.
If I am right, then creating a Boost macro for these data layout #pragmas for BCB and VC++, and any other compiler which lets one fix data layout details such as packing from within each header file, will not work. In that case the alternative of a easily remembered header file name, which contains the appropriate #pragma, is a good alternative for adding such #pragmas in the correct place of header files which need such data layout reliability.
Well, #pragmas that the compiler doesn't understand are supposed to be ignored. However, using a header for it is also a good option. You can even use a macro to introduce the header if you like:
#include CREATE_PRAGMA()
Will the above really work ? I was always pretty sure that #includes have to be processed before macros are expanded and not after.