Re: [PATCH doc] update -dM to mention excluded macros (PR 41540)
On Mon, 13 Feb 2017, Martin Sebor wrote: >> +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. >> >> Is this ("their replacements may change") truefor __FILE__ as well? >> >> In any case, this may be too nit-picking, and the patch looks fine >> to me. > Thanks. __FILE__ too can change between different lines of output: > by means of a #line directive. Good point, I did not think of that. > I actually think it would be preferable if GCC printed the value of > __FILE__ and all the other macros, including the four mentioned here. > But since in response to the bug report Andrew implied that not > printing them is intentional I figured I'd just update the docs > and resolve this old bug (raised in 2009). > > That said, I find the argument that these four are special because > their value can change from line to line a weak one given that the > definition of any predefined macro can change (simply by undefining > and redefining it something else). > > Is there a better argument for not printing __FILE__ et al? Do we > want to document this or change GCC to print all macros? My personal opinion is that -dM is a debugging option and so special- casing the four macros does not seem necessary, or at least not very important. So either proceed with your patch that documents the status quo (and my original "patch looks fine to me" stands as approval if you need any), or follow your proposal to remove that special case. What do the C/C++/cpp maintainers think? Gerald
Re: [PATCH doc] update -dM to mention excluded macros (PR 41540)
On 02/12/2017 01:27 AM, Gerald Pfeifer wrote: On Tue, 7 Feb 2017, Martin Sebor wrote: 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. +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. Is this ("their replacements may change") truefor __FILE__ as well? In any case, this may be too nit-picking, and the patch looks fine to me. Thanks. __FILE__ too can change between different lines of output: by means of a #line directive. I actually think it would be preferable if GCC printed the value of __FILE__ and all the other macros, including the four mentioned here. But since in response to the bug report Andrew implied that not printing them is intentional I figured I'd just update the docs and resolve this old bug (raised in 2009). That said, I find the argument that these four are special because their value can change from line to line a weak one given that the definition of any predefined macro can change (simply by undefining and redefining it something else). Is there a better argument for not printing __FILE__ et al? Do we want to document this or change GCC to print all macros? Martin
Re: [PATCH doc] update -dM to mention excluded macros (PR 41540)
On Tue, 7 Feb 2017, Martin Sebor wrote: > 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. +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. Is this ("their replacements may change") truefor __FILE__ as well? In any case, this may be too nit-picking, and the patch looks fine to me. Thanks, Gerald
[PATCH doc] update -dM to mention excluded macros (PR 41540)
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}.