Sun Studio 12: C++ User's Guide

B.2.5 #pragma dumpmacros

#pragma dumpmacros (value[,value...])

Use this pragma when you want to see how macros are behaving in your program. This pragma provides information such as macro defines, undefines, and instances of usage. It prints output to the standard error (stderr) based on the order macros are processed. The dumpmacros pragma is in effect through the end of the file or until it reaches a #pragma end_dumpmacro. See B.2.6 #pragma end_dumpmacros. You can substitute the following arguments in place of value:




Print all macro defines 


Print all macro undefines 


Print information about the macros used 


Print location (path name and line number) also for defs, undefs, and use


Print use information for macros used in conditional directives 


Print all macros defines, undefines, and use information for macros in system header files 

Note –

The sub-options loc, conds, and sys are qualifiers for defs, undefs and use options. By themselves, loc, conds, and sys have no effect. For example, #pragma dumpmacros=loc,conds,sys has no effect.

The dumpmacros pragma has the same effect as the command line option, however, the pragma overrides the command line option. See A.2.120 -xdumpmacros[=value[,value...]].

The dumpmacros pragma does not nest so the following lines of code stop printing macro information when the #pragma end_dumpmacros is processed:

#pragma dumpmacros (defs, undefs)
#pragma dumpmacros (defs, undefs)
#pragma end_dumpmacros

The effect of the dumpmacros pragma is cumulative. The following lines

#pragma dumpmacros(defs, undefs)
#pragma dumpmacros(loc)

have the same effect as

#pragma dumpmacros(defs, undefs, loc)

If you use the option #pragma dumpmacros=use,no%loc, the name of each macro that is used is printed only once. If you use the option #pragma dumpmacros=use,loc the location and macro name is printed every time a macro is used.