Boost logo

Boost Users :

From: Paul Mensonides (yg-boost-users_at_[hidden])
Date: 2003-03-06 20:05:55


Edward Diener wrote:

>> 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.

Yes. Actually, it works on all compilers too. The file-iteration mechanism,
among other things, of the pp-lib uses this behavior all the time. More
specifically though, both the Python library and the MPL both use file-iteration
extensively.

Technically speaking, the #line, #include, #if, and #elif directives must be
macro-expanded. For #error and #pragma directives, the behavior is unspecified,
but the C99 standard explicitly says that #pragma's of the form:

#pragma STDC xyz

...are _not_ macro expanded, even if other #pragma's are. All other directives
make no sense to macro-expand. (#define, #undef, #else, #endif)

Regards,
Paul Mensonides


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