473,382 Members | 1,766 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,382 software developers and data experts.

preprocessor, token concatenation, no valid preprocessor token

Hi

the following code the g++ (g++ (GCC) 3.3.3 (Debian 20040422)) emits the
error message that pasting of :: and hello is no valid preprocessor token.
The g++ 2.95.3 accepts the code. I know that handling of the ##
preprocessing operator has changed.

How I have to change the macro definiton of A(P)?
NO changes at macro calling should be necessary!

Thanks in advance!

#define A(P)****int*P##hello(void)*{return*1;}

class B {
public:
********B()*{
****************b*=*1;
********}

********private:
************************int*b;
************************int*hello();
};

A(D40);
A(B::);

int main(void)**{
}
Jul 22 '05 #1
1 2444
Cronus wrote:
Hi

the following code the g++ (g++ (GCC) 3.3.3 (Debian 20040422)) emits
the error message that pasting of :: and hello is no valid
preprocessor token. The g++ 2.95.3 accepts the code. I know that
handling of the ## preprocessing operator has changed.

How I have to change the macro definiton of A(P)?
NO changes at macro calling should be necessary!


In general, it is not possible to do this. Pasting '::' to 'hello' is undefined
behavior, and you can't make an identifier out of two other identifiers without
token-pasting. Instead, you should get rid of the concatenation and pass the
entire name:

#define A(id) int id(void) {return 1;}

A(D40hello)
A(B::hello)

Further, it is extremely likely that there is a better way to do whatever it is
you're doing (such as tag dispatch + ADL).

Regards,
Paul Mensonides
Jul 22 '05 #2

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

Similar topics

21
by: Eric | last post by:
Hello all, I've got this line of given code (cannot change this; wizard-generated, but value may change someday): #define IDB_BUTTON 225 Somewhere in the code I found /...
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...
3
by: michael.martin | last post by:
Hi, I am wondering if something like this is possible? #define COLON ":" #define PERIOD "." #define WORD "word" #define WORD_COLON WORD+COLON
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....
4
by: unifire | last post by:
Hi I use a define like this to search an element in a linked list #define SEARCH_NEXT( _Block, _Queue) { _Block = _Block->##_Queue.pNext; }
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
1
by: Guenter Dannoritzer | last post by:
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...
4
by: Mamluk Caliph | last post by:
For quite some time I've used code as the following to be able to "cut&paste" parts from different headerfiles of the same name. It has worked with GCC, MS, Borland, Keil to name a few. In...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.