Skip to contentSkip to conversation

Inquiry on the pre-processor

Linux-ia64 Robboy, David G 2 participants 2 messages Jul 3, 2001 – Jul 4, 2001

lore
Share & tools
lore
#0 lore raw

The C preprocessor doesn't recognize macros that are suffixed on words. It likes to substitute whole words. Does anyone know a trick to get it to substitute text for suffixes? Someone has to have done this before.

What I want to do specifically is for ia32 assembly language, but the question is about preprocessing in general. On certain assembly instruction opcodes, I want to suffix a macro that can be changed to the letter "b," "w," or "l," so that a single source program can operate on different sized operands.

Thanks,
David Robboy

#1 lore raw
Quoted 5 lines · David G

What I want to do specifically is for ia32 assembly language, but the question is about preprocessing in general. On certain assembly instruction opcodes, I want to suffix a macro that can be changed to the letter "b," "w," or "l," so that a single source program can operate on different sized operands.

#define OP_SUFFIX(op) (op##b)

Unfortunately ## only works inside macros so you have to write OP_SUFFIX(op) instead of op##suffix.