How to resolve "section type conflict" compile error and recommendations on using section attribute with gcc

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"))) 
+3
gcc android embedded android-ndk
source share
2 answers

I have the same problem. And my situation is that I put the code and variables in the same section. After I put the variable in another section, the problem was rejected. Hope this helps.

0
source share

"# define the attribute DB_SEGMENT (( section (" DBSegment ")))"

I see a space between # and determine what is wrong.

Delete this place and try to compile.

0
source share

All Articles