I’m trying to do something like:
#define __attribute__((aligned(2))) __attribute__((space(prog),aligned(2)))
but the compiler yields :
error: "(" may not appear in macro parameter list
Questions: What gives? How can I do a literal text replace, no bells, no frills ?
This is not possible with the C preprocessor. You can only define “literal txt replace”s, as you put it, if the text you want to replace is a single identifier (“object-like macro” in C standard parlance). What you wrote causes the preprocessor to think you’re trying to define a “function-like macro”, with a parameter named “
(aligned(2))“, which is a syntax error.I would deal with this problem by wrapping the entire
__attribute__construct in an object-like macro:and then replacing
__attribute__((aligned(2)))withATTRIBUTE_ALIGNED_2throughout the source code.