[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540 Martin Sebor changed: What|Removed |Added Status|ASSIGNED|NEW Assignee|msebor at gcc dot gnu.org |unassigned at gcc dot gnu.org --- Comment #6 from Martin Sebor --- No longer working on this.
[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540 Martin Sebor changed: What|Removed |Added Keywords||documentation, patch Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2017-02-07 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #5 from Martin Sebor --- A documentation-only patch posted for review: https://gcc.gnu.org/ml/gcc-patches/2017-02/msg00560.html
[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
--- Comment #1 from pinskia at gcc dot gnu dot org 2009-10-02 16:21 --- __FILE__ is dependent on # markers and #line markers in the preprocessed source so this is invalid. __LINE__ is also dependent too. If you look at the preprocessed source you will notice still some # in there. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540
[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
--- Comment #2 from msebor at gmail dot com 2009-10-02 16:39 --- I don't have a strong objection to not including __FILE__ and the rest of standard predefined macros (e.g., __LINE__, __DATE__ and __TIME__) in the output if that's by design but I would expect the documentation to mention that some macros are deliberately left out. As it stands, it states that all macros are defined, which is clearly not the case. I suggest clarifying the documentation by changing the paragraph quoted above to read: Instead of the normal output, generate a list of `#define' directives for the majority of macros defined during the execution of the preprocessor, including predefined macros (the standard macros __DATE__, __FILE__, __LINE__, and __TIME__ are excluded from this list). This gives you a way of finding out what is predefined in your version of the preprocessor. I'm not familiar with the process for updating gcc docs but if you point me in the right direction I would be happy to submit a patch. -- msebor at gmail dot com changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540
[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
--- Comment #3 from pinskia at gcc dot gnu dot org 2009-10-02 16:57 --- Hmm, considering the C99 standard has a footnote about __FILE__ (149) 149) The presumed source file name and line number can be changed by the #line directive. So of course it is hard to define these in the preprocessed source. I really don't think there should be a note about these predefined macro names based on what is mentioned in the standard. Since they are dependent on the file that is being compiled (not preprocessed). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540
[Bug preprocessor/41540] -dM -E doesn't #define __FILE__
--- Comment #4 from msebor at gmail dot com 2009-10-02 18:00 --- I understand that the values of __FILE__ and __LINE__ change within the same translation unit and thus may not be meaningful in the output of -dM -E. But the values of __DATE__ and __TIME__ do not change within a translation unit and so they could and IMO should be included in the output. In any case, since the preprocessed output contains all the standard macros expanded, I think it's reasonable to either see them all in the output of -dM -E or the discrepancies between the two kinds of output to be mentioned in the docs. I don't insist on including an exhaustive list of all macros excluded from the output if this list is large or changes depending on compiler options etc. but I do think that the docs ought to be clarified so as not to state that *all* macros are output. Here's a small test program to show the discrepancies: $ cat u.c gcc -E u.c gcc -E -dM u.c | grep -e__DATE__ -e__FILE__ -e__LINE__ -e__STDC__ -e__STDC_HOSTED__ -e__STDC_VERSION__ -e__TIME__ char date[] = __DATE__; int line = __LINE__; char file[] = __FILE__; char time[] = __TIME__; int stdc = __STDC__; int stdc_hosted = __STDC_HOSTED__; # 1 u.c # 1 built-in # 1 command-line # 1 u.c char date[] = Oct 2 2009; int line = 2; char file[] = u.c; char time[] = 11:52:51; int stdc = 1; int stdc_hosted = 1; #define __STDC_HOSTED__ 1 #define __STDC__ 1 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41540