This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Preprocessor behavior


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]