Determining Which Settings Are Saved and Restored

Not all pragma settings are saved and restored by pragmas push and pop. Pragmas that do not change compiler settings are not affected by push and pop. For example, pragma message cannot be saved and restored.

The following listing shows an example that checks if the ANSI_strict pragma setting is saved and restored by pragmas push and pop.

Listing: Testing if pragmas push and pop save and restore a setting

/* Preprocess this source code. */

#pragma ANSI_strict on

#pragma push

#pragma ANSI_strict off

#pragma pop

#if __option(ANSI_strict)

#error "Saved and restored by push and pop."

#else

#error "Not affected by push and pop."

#endif