I'm working with a microcontroller and want to write a macro that inserts a specific number of wait cycles. I want
DELAY_CYCLES(40)
to expand to
__asm(" RPT #40 || NOP");
Additional restrictions:
Since this is a compiler-specific intrinsic it needs to match exactly. I can't rely on the compiler to merge strings. E.g.
__asm(" RPT #""40"" || NOP");is not correct.The manufacturer headers already define:
#define NOP __asm(" NOP")I can't pass a string to the intrinsic.
char str = " RPT #40 || NOP"; __asm(str);is not allowed.
At the moment I am not even sure if there is a solution to this special case.
__asm(" RPT #""40"" || NOP");? __asm syntaxes in most compilers will process this just fine.echo 'char *x = "a""b";' | gcc -xc -E -; this printschar *x = "a""b";)"\x1234"is an invalid escape sequence, but"\x12""34"compiles.