Next: , Previous: Types, Up: Top



6 Representation of #define and #undef

This section describes the stabs support for macro define and undefine information, supported on some systems. (e.g., with -g3 -gstabs when using GCC).

A #define macro-name macro-body is represented with an N_MAC_DEFINE stab with a string field of macro-name macro-body. An #undef macro-name is represented with an N_MAC_UNDEF stabs with a string field of simply macro-name. For both N_MAC_DEFINE and N_MAC_UNDEF, the desc field is the line number within the file where the corresponding #define or #undef occurred.

For example, the following C code:

         #define NONE	42
         #define TWO(a, b)	(a + (a) + 2 * b)
         #define ONE(c)	(c + 19)
     
         main(int argc, char *argv[])
         {
           func(NONE, TWO(10, 11));
           func(NONE, ONE(23));
     
         #undef ONE
         #define ONE(c)	(c + 23)
     
           func(NONE, ONE(-23));
     
           return (0);
         }
     
         int global;
     
         func(int arg1, int arg2)
         {
           global = arg1 + arg2;
         }

produces the following stabs (as well as many others):

         .stabs	"NONE 42",54,0,1,0
         .stabs	"TWO(a,b) (a + (a) + 2 * b)",54,0,2,0
         .stabs	"ONE(c) (c + 19)",54,0,3,0
         .stabs	"ONE",58,0,10,0
         .stabs	"ONE(c) (c + 23)",54,0,11,0

NOTE: In the above example, 54 is N_MAC_DEFINE and 58 is N_MAC_UNDEF.