Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > #, ## preprocessor operator weirdness with g++

Reply
Thread Tools

#, ## preprocessor operator weirdness with g++

 
 
Guenter Dannoritzer
Guest
Posts: n/a
 
      11-24-2007
Hi,

I have a piece of code that got developed using Microsoft .NET 2003 and
I try to compile it with g++/gcc 4.1.2.

There is a problem with the string concatenation operator for the
preprocessor. The following is a piece of code:

#define GET_DOUBLE_PARM_ARRAY(X,N) {X =
ParmInput->GetDoubleParmArray(#X##"\0",X,N);}

which causes the following error message:

error: pasting ""A_Coeffs"" and ""\0"" does not give a valid
preprocessing token

when called like this:

GET_DOUBLE_PARM_ARRAY(A_Coeffs, ar_size);

I had other cases where the concatenation operator was used in
connection with a cout stream and I just replaced it by <<. But here I
have no idea how to solve it.

Can anybody give me some help how to resolve that?

Why does g++ not like this?

Thanks for your help.

Cheers,

Guenter

 
Reply With Quote
 
 
 
 
Justin Spahr-Summers
Guest
Posts: n/a
 
      11-24-2007
On Nov 23, 6:31 pm, Guenter Dannoritzer <kratfkryk...@spammotel.com>
wrote:
> Hi,
>
> I have a piece of code that got developed using Microsoft .NET 2003 and
> I try to compile it with g++/gcc 4.1.2.
>
> There is a problem with the string concatenation operator for the
> preprocessor. The following is a piece of code:
>
> #define GET_DOUBLE_PARM_ARRAY(X,N) {X =
> ParmInput->GetDoubleParmArray(#X##"\0",X,N);}
>
> which causes the following error message:
>
> error: pasting ""A_Coeffs"" and ""\0"" does not give a valid
> preprocessing token
>
> when called like this:
>
> GET_DOUBLE_PARM_ARRAY(A_Coeffs, ar_size);


The preprocessor concatenation operator is used for *token*
concatenation, not *string* concatenation. To concatenate two strings,
one only has to place them next to each other. For instance,

const char *s = "foo" "bar";
std::cout << s << '\n';
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tr operator weirdness Bernhard Singer Perl Misc 6 12-14-2006 08:05 PM
Preprocessor concatenation of operator and ... mrstephengross C++ 8 10-12-2005 03:58 AM
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
Tkinter WEIRDNESS or Python WEIRDNESS? steve Python 4 03-13-2005 12:34 AM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM



Advertisments