Context
My team upgraded our project from using Arm Compiler for Embedded 5 to Embedded 6. In our code, we place data at a specific location in RAM like so:
#define RAM_START_ADDR <some constant>
#define OFFSET <some other constant>
...
volatile my_datatype_t __attribute__((at(RAM_START_ADDR + OFFSET))) var = ...;
But for some reason, Embedded 6 no longer supports __attribute__((at(<addr>))), and instead, we need to use __attribute__((section(".ARM.__at_<addr>"))). As you might have noticed, the address we are dealing with is an arithmetic expression, which is not supported by __attribute__(section), which expects a numeric string argument. ARM does provide a workaround, namely
volatile my_datatype_t * const var = (volatile my_datatype_t *) (RAM_START_ADDR + OFFSET);
Except, when this compiles, rather than allocating space for var, it just overwrites whatever data is at RAM_START_ADDR + OFFSET. Haven't asked ARM how to achieve this, but I'm not confident we'll get anything besides the not-working workaround they already provide.
Question
Is there a way to evaluate a constant arithmetic expression at compile-time and format it as a string? If so, then we could still use __attribute__((section)) and just pass it the numeric string.
I've done a lot of research, and there doesn't seem to be a way to define a macro such that the expression is evaluated and the value is accessible as a token or string or anything.
You are out of luck. This is a preprocessor, if you want to add anything you have to hard-code all possible combinations. This has to be generated with a script. You can try searching for an existing project like Boost, but I do not know or see anything relevant,
BOOST_PP_LIMIT_MAGis max 1024.