preprocessor token

U

unifire

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
 
L

Laurent Deniau

unifire said:
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.
 
W

Walter Roberson

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; \
[...] \
}
 
K

Kenneth Brody

unifire said:
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:[email protected]>
 
P

Peter Nilsson

Walter said:
<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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top