#pragma push and pop

Kevin Buettner kev@primenet.com
Tue, 5 Sep 2000 13:12:17 -0700


On Sep 5, 11:13am, Lucas Vogel wrote:

> I am looking at DLL code on an MS platform, containing this line:
> 
> #pragma warning(pop)
> 
> MSDN says that #pragma is a place for operating-system specific features
> while remaining compliant with standard C++. Does Linux have a push/pop
> #pragma?

I think you're asking the wrong question.  The question you really
want to ask is "Does the GNU C/C++ compiler for Linux have a push/pop
#pragma?"

If you read the GCC manual, it would appear that the answer is "no."
The authors of the GCC manual strongly disapprove of pragmas and
provide the following reasons for this disapproval:

   1. It is impossible to generate #pragma commands from a macro. 
   2. There is no telling what the same #pragma might mean in another
      compiler.  

However, I just took a look at the current gcc development sources and
see the following in config/linux.h:

    /* Define this so we can compile MS code for use with WINE.  */
    #define HANDLE_PRAGMA_PACK_PUSH_POP

Moreover, there is a decent chunk of code in c-pragma.c which appears
to implement this functionality, so I would suspect that the answer
is actually "yes."

(I don't know what this pragma is supposed to do, so I was unable to
test it...)

Kevin