Print this page
cpp: make it easier to find macro sources
This is a dubiously useful hack, but invaluable when debugging the
preprocessor.
If CPP_DEBUG_DEFINITIONS is in the environment, output to stderr at
every macro definition its name, and the defining file and line number,
such that the operative definition of common macros (such as __P) can be
determined.

@@ -819,10 +819,13 @@
                 while (*inp!='\n')
                         p=skipbl(p);
                 return(p);
         }
         np=slookup(pin,p,1);
+        if (getenv("CPP_DEBUG_DEFINITIONS") != NULL)
+                fprintf(stderr, "*** defining %s at %s:%d\n",
+                    np->name, fnames[ifno], lineno[ifno]);
         if ((oldval=np->value) != NULL)
                 savch=oldsavch; /* was previously defined */
         b=1; cf=pin;
         while (cf<p) {/* update macbit */
                 c= *cf++; xmac1(c,b,|=); b=(b+b)&0xFF;