3

The C standard now says:

The ability to undefine and redefine the macros bool, true, and false is an obsolescent feature and may be removed in a future version.

That is, stdbool.h is deprecated. But no rationale is given and I couldn't find one. Do they intend on adding bool as a basic type for good or is there something else ?

If you happen to know why this is deprecated, thank you for telling me !

Lærne
  • 3,010
  • 1
  • 22
  • 33

2 Answers2

6

There are a few misunderstandings in your question:

  • The first is that you link to a POSIX reference, which often follow the C Standard, but it doesn't have to.

  • The section you quote from is informative and not factual, and as such may not reflect the C standard at all. And as such it isn't authoritative either.

  • The quote also says it's the ability for users to undefine or redefine the macros is what could be taken away. The macros in the <stdbool.h> header file would not be affected by this.

  • Lastly, it also says the possibility might be taken away, not that it will or have been.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
6

Why is stdbool.h deprecated?

It's not.

You quoted the following note:

The ability to undefine and redefine the macros bool, true, and false is an obsolescent feature and may be removed in a future version.

What this means is that the following paragraph may be removed in the future:

An application may undefine and then possibly redefine the macros bool, true, and false.

That does not mean that the header or its contents will be removed.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • I think the intention of that text is to allow `` to do something other than defining `true` and `false` as macros equivalent to `0` and `1` (e.g. define them as macros which expand to compiler intrinsics `__true` and `__false`--perhaps to help a compiler generate more useful diagnostics). Such handling would be undermined by an application that undefined those macros and redefined them as 0 and 1. – supercat Jul 13 '18 at 16:38
  • but that doesn't mean that `` is deprecated.... I'm afraid. What it probably means is that because the existence of `` header, ***the task of defining macros for `true` or `false` and `bool` is what is deprecated.*** – Luis Colorado Jul 13 '18 at 16:51