Inquiry on the pre-processor
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
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.