C99定義了關鍵字 _Bool, 又另外新增了stdbool.h
將
#define bool _Bool
#define true 1
#define false 0
為什麼用_Bool這樣看起來有點奇怪的命名而不直接定義bool?
最主要的原因是因為在c89 bool並非保留字,
因此在擴展規範時只能從reserved identifier下手了
在c89的規範 7.1.3第一項提到
All identifiers that begin with an underscore and either an uppercase letter or
another underscore are always reserved for any use.
February 2025 S M T W T F S « Jan 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 -
Recent Posts
Recent Comments
Categories
Links