I use Android NDKr8 and the gcc extension to compile some library code that is used on different platforms, including some built-in ones. This code uses segments to put a bunch of items in contiguous memory space. The compilation generates "error: variable_name causes a section type conflict".
We use a macro to declare a segment attribute:
# define DB_SEGMENT __attribute__ ((__section__ ("DBSegment")))
The above variable name is declared as follows:
dbStruct const variable_name[] DB_SEGMENT = { {conststringvalue0, sizeof(conststringvalue0)}, β¦more like this };
dbStruct
typedef struct dbStruct { const char * const address; const UINT16 stringSize; } dbStruct;
conststringvalue0 is declared like this:
const char conststringvalue0[] DB_SEGMENT = "some string value";
The same code is compiled into Xcode using its default compiler with a slight modification to the macro declaration DB_SEGMENT. It's deeper than C than I'm used to, so any help would be appreciated. Google has some links to the error, but the fix for it is unclear. Is there a more efficient strategy for creating a specific piece of continuous memory?
In response to the comment, here is the only difference from correctly compiling the version on Xcode:
#define DB_SEGMENT __attribute__ ((section ("DBSegment,DBSection")))
gcc android embedded android-ndk
jjhorgan
source share