Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > "does not give a valid preprocessing token"... Why?

Reply
Thread Tools

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

 
 
Frodo Baggins
Guest
Posts: n/a
 
      09-15-2004
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.
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      09-15-2004
Frodo Baggins <(E-Mail Removed)> 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!
 
Reply With Quote
 
 
 
 
Joona I Palaste
Guest
Posts: n/a
 
      09-15-2004
Frodo Baggins <(E-Mail Removed)> 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 ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Make money fast! Don't feed it!"
- Anon
 
Reply With Quote
 
Frodo Baggins
Guest
Posts: n/a
 
      09-16-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros : error: pasting does not give a valid preprocessing token girishk.k4 C Programming 0 03-23-2013 12:12 PM
GIVE ME FILM OR GIVE ME DEATH l#vfgsgEg@AO1.com DVD Video 4 07-14-2005 03:10 PM
macros: not a valid preprocessing token Chris C Programming 5 05-11-2005 02:52 PM
Give us 3 minutes; we give you the whole library lib Computer Support 1 02-04-2005 03:16 AM
Give us 3 minutes; we give you the whole library lib Computer Support 0 01-27-2005 07:52 AM



Advertisments