This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How I can create unpacked enum in Strict ANSI mode?



In relaxed mode I can create unpacked enum using next construction

typedef enum {
    one = 1,
    two = 2
} __attribute__((__unpacked__)) enum_t;

But in strict mode I get error " line 183: error #2104: attribute "__unpacked__" does not apply here"

I don't want to create fake enum entries.

  • The short answer is that you can't. Strict ANSI mode is not required to accept any programs other than programs which are strictly conforming, and this program is not, because it relies on non-standard features. My advice in this case is to compile in non-strict mode. The long answer is... well, the short version of the long answer is that the compiler could be changed to accept this, but it's not likely to happen in the near future.
  • Vladimir Romanov said:
    I don't want to create fake enum entries.

    Then the only other method is to use the build option --enum_type=int.  I hope that is practical for your situation.

    Thanks and regards,

    -George