Does gcc define anything when -g is specified?

前端 未结 3 1256
忘掉有多难
忘掉有多难 2020-12-14 05:25

Shortly, I want to know if gcc (or g++. I need it in C, but also am curious about c++) defines any special symbols if -g is enabled. Does it? I

3条回答
  •  别那么骄傲
    2020-12-14 06:08

    As others have said, and as is apparent from the manual, GCC does not provide any intrinsic macros that indicate whether debug information will be generated (-g mode). What I want to add, is that this is on purpose.

    Long, long ago, the original authors of GCC (RMS, Kenner, probably a couple others) decided that enabling debugging information should not cause any changes whatsoever to the actual code, to reduce the risk of a bug mysteriously vanishing when you try to debug it. This is a bedrock design principle in GCC, and even today the developers go out of their way to maintain it.

    Defining a macro would violate this design principle, since it would permit the source code to change itself in response to -g.

提交回复
热议问题