I have a problem with the #define in C
I am using MSP430F5418 with IAR EW 5.10
I have a pragma called location which will put the next declaring variable to the specified segment.
In the below example a will put into the segment called myseg and b is not.
#pragma location="myseg" static const char a[] = "amma"; static const char b[] = "amrita";
I have a lot of constants like this.
I want to know whether I could do something like this…
#define TYPE location="myseg" \
static const char
#pragma TYPE a = "amma";
#pragma TYPE b = "amrita";
.....
so that I can avoid #pragma location="myseg" before each variable declaration.
You cannot use a
#pragmainside a#define, nor the other way round.To circumvent this restriction, some compilers offer a
_Pragmaoperator (GCC, LLVM) (__pragmain Visual C++) which provide the same functionality as the#pragmadirective. This operator can be used in another macro. Find out whether your compiler supports such a pragma operator.Using this, you could write: