5

With GCC, I can do this:

typedef struct {
    char a;
    int n;
} MyStruct;

MyStruct ms __attribute__((section("MySection"))) = {'x', 33};
MyStruct *pms = &ms;

But when I use compound literal as follows, GCC complains warning: 'section' attribute does not apply to types [-Wattributes].

typedef struct {
    char a;
    int n;
} MyStruct;

MyStruct *pms = &(MyStruct __attribute__((section("MySection")))){'x', 33};

Is there any way to get by? Thank you.

dingcurie
  • 121
  • 6

0 Answers0