473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

#, ## preprocessor operator weirdness with g++

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

Nov 24 '07 #1
1 3292
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';
Nov 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mrstephengross | last post by:
I'm using gcc 3.3.1 to compile the following code (below). I've written a macro to simplify writing operators. The macro uses the '##' operator to paste together 'operator' and the name of the...
13
by: Chris Croughton | last post by:
Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? #include <stdio.h> #define DEF defined XXX int main(void) { int...
9
by: Walter Roberson | last post by:
I have run into a peculiarity with SGI's C compiler (7.3.1.2m). I have been reading carefully over the ANSI X3.159-1989 specification, but I cannot seem to find a justification for the behaviour....
0
by: Leszek Taratuta | last post by:
Hello, I have the following code snippet that overloads the "-" operator: // unary public static Vector operator -( Vector v ) { return new Vector( -v.X, -v.Y ); }
10
by: Pieter Breed | last post by:
Hi All, Please excuse me, but the bulk of my post will be a code post. It describes some weirdness with regards to the implicit casting operator. The crux of the problem is this: I want to...
14
by: dan | last post by:
I would like to have the preprocessor automatically generate the number of array elements requested. Each element is zero. The elements get pasted into a larger array. The other elements may be...
36
by: anon.asdf | last post by:
Hello! Can the proprocessor make conditional decisions. Here's an example of the functionality (not standard C!) #define PUT_BYTE(const_index, val) \ #preprocessor_if (const_index ==...
3
by: Martin T. | last post by:
Hello. I tried to overload the operator<< for implicit printing of wchar_t string on a char stream. Normally using it on a ostream will succeed as std::operator<<<std::char_traits<char> will...
10
by: abir | last post by:
Hi, This is not strictly a C++ language question. Is there any way to form a string from an identifier with the preprocessor with some operations ? i.e to say to make a string from an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.