[cfe-dev] Preprocessor macros

Peter Stirling peter at pjstirling.plus.com
Wed Aug 13 17:29:09 PDT 2014


Is there a way to detect code that declares a function, and then uses 
the preprocessor to define calls to it as empty? i.e. code that does:

extern int _IO_ftrylockfile (_IO_FILE *);
# define _IO_ftrylockfile(_fp) /**/

I've had a rather confusing debugging session where I thought maybe 
seeing different prototypes due to preprocessor directives. Compiling my 
generated code was giving me the (not entirely helpful) error message:

dummy.cc.cc:2641:3: error: non-void function '__ffi$580' should return a 
value [-Wreturn-type]

   return _IO_ftrylockfile($arg0);

When I grep'd the preprocessor output for the prototype it was shown 
correctly, but it was only when I searched for the call site that I saw 
what was really going on.

More information about the cfe-dev mailing list