I had hoped to be able to define a macro I could invoke as DECLARE_INTERRUPT(USCI_B2_VECTOR) that would be portable across various compilers to add the annotations necessary to mark a function as an interrupt handler (in this case, for USCI_B2_VECTOR). In the case of the TI MSP430 compiler it should emit the equivalent of:
#pragma vector=USCI_B2_VECTOR
Since #pragma can't be used in macros, I tried using:
#define BSP430_CORE_DECLARE_INTERRUPT(iv_) _Pragma("vector=" #iv_) void
which produces:
_Pragma("vector=" "USCI_B2_VECTOR")
Unfortunately this produces a syntax error "expected a )", while:
_Pragma("vector=USCI_B2_VECTOR")
processes correctly. My best guess is the compiler won't catenate the adjacent strings when preprocessing, though it does so correctly when adjacent string literals appear in code. (This is with msp430 compiler version 4.1.1, on the command line in Linux.)
Since _Pragma requires a string parameter, it would be rather more useful if standard preprocessor techniques to compose a string literal from macro arguments would work.
Or is there an alternative solution that escapes me at the moment?