Enum usage

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Enum usage

1,343 次查看
bengtandersson
Contributor III

I am writing a application in C for 5602B and I'm using enum:s in a way that I'm not absolutely  sure is OK.

 

enum

{

     variablesStartAddress = 0,

 

     channelMaskAddress = variablesStartAddress,

 

     dockingParamsAdress = channelMaskAddress + sizeof(tChannelMaskParam)

 

 

 

};

 

For C++ I have found proof that it is OK to use previous elements in the enumeration list to asign a value to an element but not for C. This compiles and builds without problems for me but that doesn't necessarily mean that it is supported. Is this OK in CW10.6??

标签 (1)
0 项奖励
回复
1 回复

1,242 次查看
martin_kovar
NXP Employee
NXP Employee

Hi,

I tried this construction in CW10.6 and it seems it is OK. But only remember that two elements will have the same value.

Regards,

Martin

0 项奖励
回复