What is the advantage of using negative enums

In the example of the kaleidoscope / AST analyzer in LLVM, the enumeration receives all negative values. Why is the minus sign?

enum Token {
  tok_eof = -1,
  // commands
  tok_def = -2, tok_extern = -3,
  // primary
  tok_identifier = -4, tok_number = -5
};
+3
source share
2 answers

C- . , , , , - "undefined". , tok >= 0.

+3

, .

0 255, tok_eof. , 0 255 , , 256, 257, 258 .. , 256, 257, 258 IMO.

+2

Source: https://habr.com/ru/post/1742743/


All Articles