467,869 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,869 developers. It's quick & easy.

"does not give a valid preprocessing token"... Why?

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.
Nov 14 '05 #1
  • viewed: 20269
Share:
3 Replies
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
Nov 14 '05 #2
Frodo Baggins <fr************@here.com> writes:
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)


Remove the second ##. It looks like its inclusion was a mistake.
--
Here's a tip: null pointers don't have to be *dull* pointers!
Nov 14 '05 #3
On Wed, 15 Sep 2004 18:14:31 +0000, Joona I Palaste wrote:
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.


That was it exactly. Thank you both Joona and Ben. :)
Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Stephen Oakes | last post: by
1 post views Thread by Lauchlan M | last post: by
4 posts views Thread by lisa | last post: by
3 posts views Thread by =?Utf-8?B?Sm9uIEU=?= | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.