Why are C booleans called _Bool?

后端 未结 3 1483
旧时难觅i
旧时难觅i 2021-02-12 13:03

Why does C use the word _Bool to define boolean values? Whereas they use the word float for floats and not _Float?

Furthermore, wh

3条回答
  •  不要未来只要你来
    2021-02-12 13:30

    _Bool was not originally in C, but was added in the 1999 C Standard. If it had been called bool then a large amount of existing code would break because many projects made their own type alias bool already.

    The C89 standard set aside identifiers starting with _ followed by upper-case character as reserved for implementation use. This is why new features added to C always start with such names. _Complex, _Alignof and _Static_assert are other examples.

    There is also a header which aliases bool to _Bool and defines true and false ; this header can be included by new projects or by projects that didn't already define bool.

提交回复
热议问题