This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Preprocessor behavior
- To: Munagala Ramanath <Munagala dot Ramanath at postx dot com>
- Subject: Re: Preprocessor behavior
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Mon, 16 Oct 2000 13:42:21 -0700
- Cc: gcc at gcc dot gnu dot org
- References: <A15D4A2B0915D21180F600805F9F7117019EE776@mail.postx.com>
On Mon, Oct 16, 2000 at 01:26:31PM -0700, Munagala Ramanath wrote:
> Hi,
>
> Using the macro:
> #define T( X ) L ## X
> to create a wide string fails with the predefined __FILE__ symbol
> (i.e. T(__FILE__)) with gcc-2.95.2 on Sparc/Solaris7 because it
> apparently catenates the body to get L__FILE__ before rescanning.
>
> MSVC yields the expected L"<filename>".
MSVC is buggy, gcc's behavior is correct. The tokens on either side
of a ## are not to be macro-expanded before pasting - C99 6.10.3.3
paragraph 2.
You can get the behavior you wanted with an extra macro layer:
#define WIDESTR(x) WIDESTR_(x)
#define WIDESTR_(x) L##x
#define WIDEFILE WIDESTR(__FILE__)
which should still work with MSVC.
zw