Skip to contentSkip to conversation

warnings appearing during preprocessor string concatenation (##)

DISCUSSION Jamie Risk 2 participants 2 messages Mar 5, 2003 – Mar 6, 2003

lore
Share & tools
lore

Jamie Risk

author
#0 lore raw

I have the following line in my code,

#define FEATURE(select) feature_structure. ## select ## .member
...
FEATURE(test);

and when I run it through the compiler (gcc 3.2.2 on Linux x86) I get the _warning_

file.c:111:32: warning: pasting "." and "test" does not give a valid
preprocessing token
file.c:111:32: warning: pasting "test" and "." does not give a valid
preprocessing token

If I look at the preprocessor output, (gcc's -E option) it produces what I'm hoping for, although I'd like to avoid the warning. Suggestions?

- Jamie

Reply to "gmane.linux.c-programming" or me directly.

#1 lore raw
Quoted 9 lines · Jamie Risk

I have the following line in my code,

#define FEATURE(select) feature_structure. ## select ## .member
...
FEATURE(test);

and when I run it through the compiler (gcc 3.2.2 on Linux x86) I get the _warning_

Quoted 7 lines

file.c:111:32: warning: pasting "." and "test" does not give a valid
preprocessing token
file.c:111:32: warning: pasting "test" and "." does not give a valid
preprocessing token

If I look at the preprocessor output, (gcc's -E option) it produces what I'm hoping for, although I'd like to avoid the warning. Suggestions?

Just remove the '##' operator. The preprocessor is right here, there is nothing to concatenate to a token in your example.

Robert

Signature · 2 lines
Robert Schiele			Tel.: +49-621-181-2517
Dipl.-Wirtsch.informatiker	mailto:[email protected]