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

preprocessor token

Hi

I use a define like this to search an element in a linked list

#define SEARCH_NEXT( _Block, _Queue)
{
[...]
_Block = _Block->##_Queue.pNext;
[...]
}

now, I get the following error:

pasting "->" and "Queue" does not give a valid preprocessing token

does anyone know some god literature about this issue

thx

Feb 13 '06 #1
4 1978
In article <11**********************@g44g2000cwa.googlegroups .com>,
unifire <un*****@gmx.net> wrote:
I use a define like this to search an element in a linked list
#define SEARCH_NEXT( _Block, _Queue)
{
[...]
_Block = _Block->##_Queue.pNext;
[...]
} now, I get the following error: pasting "->" and "Queue" does not give a valid preprocessing token does anyone know some god literature about this issue


Is there a particular reason you are not just using

#define SEARCH_NEXT( _Block, _Queue) \
{ \
[...] \
_Block = _Block->_Queue.pNext; \
[...] \
}

--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Feb 13 '06 #2
unifire wrote:
Hi

I use a define like this to search an element in a linked list

#define SEARCH_NEXT( _Block, _Queue)
{
[...]
_Block = _Block->##_Queue.pNext;
[...]
}

now, I get the following error:

pasting "->" and "Queue" does not give a valid preprocessing token
remove the ## not required here.
does anyone know some god literature about this issue


look at the definition of the ## operator and/or a token?

a+, ld.
Feb 13 '06 #3
unifire wrote:

Hi

I use a define like this to search an element in a linked list

#define SEARCH_NEXT( _Block, _Queue)
{
[...]
_Block = _Block->##_Queue.pNext;
[...]
}

now, I get the following error:

pasting "->" and "Queue" does not give a valid preprocessing token
That's because "->_Queue" is not a valid token. Remove the "##" as
it is unnecessary.
does anyone know some god literature about this issue


I hear that the Bible is pretty good, but I don't think it mentions
the C preprocessor anywhere. :-)

Hold on... Joshua 2:12 says

Now therefore, I pray you, swear unto me by the LORD, since I have
showed you kindness, that ye will also show kindness unto my father's
house, and give me a true token:

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Feb 13 '06 #4
Walter Roberson wrote:
<snip>
Is there a particular reason you are not just using

#define SEARCH_NEXT( _Block, _Queue) \
{ \
[...] \
_Block = _Block->_Queue.pNext; \
[...] \
}


I'd prefer the do { } while(0) trick over plain {}; I'd parenthesise
the first
macro parameter in the substitution text; and I'd also change the macro
parameter names...

All identifiers that begin with an underscore and either an uppercase
letter or another underscore are always reserved for any use.

--
Peter

Feb 14 '06 #5

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

Similar topics

1
by: Cronus | last post by:
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...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
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...
3
by: Charlie Zender | last post by:
Hi, I want to have a CPP macro that tests the value of a token and returns the string "No" if the token is undefined (or 0) and returns "Yes" if the token is defined (non-zero). Then I can...
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....
13
by: Henry Townsend | last post by:
I hope this is on-topic in c.l.c - it's about the C preprocessor more than the language per se, more generally about the K&R behavior, and most specifically about the Sun cpp which is why I've...
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...
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.