0

Consider the following snippet:

enum ids {
   ID1 = 1,
   ID2 = 2,
   ID3 = 3,
};

So this list can be extended with new ID. Is there a way in the C language to provide a compile time check ensuring that these IDs do not repeat each other, i.e. the following could be caught because ID100 is equal to ID2:

enum ids {
   ID1 = 1,
   ID2 = 2,
   ID3 = 3,
   ...
   ID100 = 2
};

Thanks.

Mark
  • 6,052
  • 8
  • 61
  • 129

0 Answers0