The attached documentation-only patch clarifies the description of the -dM option to mention that __FILE__ (and other predefined macros) do no appear on the list generated by the option.
Martin
PR preprocessor/41540 - -dM -E doesn't #define __FILE__ gcc/ChangeLog: PR preprocessor/41540 * doc/cppopts.texi (-dM): Update. diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 0497712..bc76809 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -481,10 +481,10 @@ conflicts, the result is undefined. @item -dM @opindex dM Instead of the normal output, generate a list of @samp{#define} -directives for all the macros defined during the execution of the -preprocessor, including predefined macros. This gives you a way of -finding out what is predefined in your version of the preprocessor. -Assuming you have no file @file{foo.h}, the command +directives for macros defined during the execution of the preprocessor, +including most predefined macros. This gives you a way of finding out +what is predefined in your version of the preprocessor. Assuming you +have no file @file{foo.h}, the command @smallexample touch foo.h; cpp -dM foo.h @@ -493,6 +493,10 @@ touch foo.h; cpp -dM foo.h @noindent shows all the predefined macros. +The predefined macros @code{__FILE__}, @code{__LINE__}, @code{__DATE__}, +and @code{__TIME__} are excluded from this list because their replacements +may change from one line of output to the next. + @ifclear cppmanual If you use @option{-dM} without the @option{-E} option, @option{-dM} is interpreted as a synonym for @option{-fdump-rtl-mach}.