Meaning of __BASE_FILE__ inside -include file?

Zack Weinberg zack@codesourcery.com
Thu Oct 14 00:22:00 GMT 2004


"Gary Funck" <gary@intrepid.com> writes:

> Hello, given the following ident-like definition living inside
> a header file:
>
> /* Place configuration information required by the Berkeley
>    UPC compilation system into the object file. */
> static const char GCCUPCConfig[] __attribute__ ((section("upc_pgm_info"))) =
>   "$GCCUPCConfig: (" __BASE_FILE__ ") "
>                    __UPC_THREADS_CONFIG__ " " __UPC_THREADS_MODEL__ "$";
>
> When this file is included via an expliict #include in the source program,
> it generates the expected result.
>
> However, when this file is (pre-) included via a -include switch
> on the command line, __BASE_FILE__ expands as "<command line>"
> (without the quotes).
>
> __BASE_FILE__ is defined as follows:
>
> This macro expands to the name of the main input file, in the form of a C
> string constant. This is the source file that was specified on the command
> line of the preprocessor or C compiler.
>
> -----------
>
> Is it reasonable to assume that __BASE_FILE__ should also produce the
> expected result when invoked from a header file included via tha -include
> switch?  Are there significant implementation issues involved in supporting
> this usage?

It sounds like there are two separate bugs.  One is that __BASE_FILE__
is somehow expanding to a non-string-constant (unless I misunderstand
you).  The other is that you get "<command line>" instead of the
desired primary source file.  I think that's a bug too, but it might
be very hard to fix (-include handing gets into heavy initialization-
order issues).

Could you clarify whether you are actually seeing __BASE_FILE__ expand
to a non-string-constant, and then file a bug in GCC Bugzilla?

zw



More information about the Gcc mailing list