set enumeration size

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

set enumeration size

619件の閲覧回数
barbercolman
Contributor III

KDS will will create a 8 or 16 bit value based on the number of elements is an enumeration. This is great for optimization but causes issues where a fixed size is expected. We worked around this issue by setting an element to 65535. But it is not clean. Is there a way to force enums to UInt16 in KDS?

ラベル(1)
0 件の賞賛
1 返信

382件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Hi Dale,

this is actually not a question about KDS, this is a question about compilers (well, gcc).

There is a good article about this topic:

http://stackoverflow.com/questions/1113855/is-the-sizeofenum-sizeofint-always

and you will find more if you search the internet e.g. for

gnu gcc force enum size

Some compilers have options to set the size. To my knowledge in gcc you only can set an option to pack (or making the enums 'short'), which is exactly what you do *not* want. So setting a dummy element with a value > one byte what I would do too. I don't see any other solution.

Erich

0 件の賞賛