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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top