|
Boost Users : |
From: Edward Diener (eddielee_at_[hidden])
Date: 2003-03-05 21:29:00
Paul Mensonides wrote:
> Edward Diener wrote:
>
>> While I agree with test cases, at the simplest level of just setting
>> the #pragmas to values, there should really be no problems. I am
>> supposing that one can set a #pragma from within a #define, but if
>> one can't, because a #define can't create another preprocessor
>> statement,
>
> It is implementation-defined whether or not the contents of a #pragma
> directive are macro expanded--I think that VC allows it. C99
> explicitly allows it, but says that any #pragma that begins with STDC
> is explicitly _not_ macro expanded. C99, of course, has the _Pragma
> operator which can be generated by a macro expansion (not that that
> is relevent here).
The opposite way was what I was wondering about. Can a #define create a
#pragma which then is picked up as a preprocessor line ? As an example will
this work:
#define CREATE_PRAGMA #pragma somepragma
// Code
CREATE_PRAGMA
// Code
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. 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net