Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring or redefining GCC Standard Predefined Macros

Is it possible to tell GCC to compile the source code, and ignore macros like __FILE__, __LINE__ , etc, etc, or redefine them to expand into let's say - an empty string?

like image 888
user1483597 Avatar asked Dec 15 '13 12:12

user1483597


1 Answers

As with any macro you can just use:

#undef __LINE__
#undef __FILE__

and then you can redefine them.

You can also pass -U macroname to undef a macro name and -D macroname=definition to define a macro name to the gcc options.

Note that, as indicated in another answer, undefining or redefining __LINE__ or __FILE__ in C invokes undefined behavior.

like image 77
ouah Avatar answered Oct 26 '22 07:10

ouah