Frodo Baggins <fr************@here.com> scribbled the following:
Hi All,
I have a piece of code (not written by me) that is failing on compile with
the error:
pasting "xdr_ndmp_connect_open_request" and "," does not
give a valid preprocessing token
The relevant line from the header is:
#define XDR_AND_SIZE(func) (bool_t(*)(XDR*, ...))xdr_##func##,sizeof(func)
Any and all help greatly appreciated.
C tokenising doesn't work like you think it does. The , (commma) that
separates function parameters is a token on its own, not part of some
greater token that comprises the entire function invocation.
In other words, your function invocation would read tokenised like this:
(
bool_t
(
*
)
(
XDR
*
,
....
)
)
xdr_func
,
sizeof
(
func
)
The ## preprocessing operator concatenates two pieces of text into one
single token. This makes the invocation read like this:
(
bool_t
(
*
)
(
XDR
*
,
....
)
)
xdr_func,
sizeof
(
func
)
See the difference? You end up with a token saying "xdr_func," (note
the comma) which is not a legal identifier, operator or punctuator.
To fix this, simply replace the second ## with a space.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\--
http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Make money fast! Don't feed it!"
- Anon