In C I am using
#ifdef my_fileC
# define extint
#else
# define extint extern
#endif
in headerfile my_file.h and then
extint int32_t my_var;
With C++17 I dropped extint and use inline:
inline int32_t my_var;
which normally works perfect. Now I used inline with variables that should be placed at predefined memory areas with attribute section:
inline int32_t my_var __attribute__ ((section("my_section")));
Unfortunatelly this does not produce the same results as using extint instead of inline. Only one variable is really placed in the desired section, the other ones are somewhere else, no compiler or linker error is given but the program crashes when reaching some point although the sources are the same except for inline replacing extint.
Anyone experienced this too? Is this a compiler or linker error or am I doing something wrong? My project is pretty large so it is hard to reduce it to a minimalistic version that still has this error. I can provide map files of the project with only the attribute section variables using extint vs all variables using inline, if that gives more information. I am using STM32 Cube IDE which has GNU tools 10.3-2021.10, compiling for STM32H7.
Thanks for any help.
Linker LD file for this section looks like this:
my_data_section (NOLOAD) : /* (NOLOAD) forces not to create init data in hex file */
{
. = ALIGN(4);
*(my_section)
. = ALIGN(4);
} >RAM_D2