Different developers have different opinions on that point, but
in any case it's irrelevant to what I was saying.
I agree that different developers have different opinions here - I am
just offering mine. And it is a little relevant, in that you are
suggesting using TRUE and FALSE because you think "true" and "false"
look like they could be variable.
Nonsense, as James Kuyper has pointed out.
One can keep habits from old systems after new ones are introduced -
such as having a habit of writing some things in all-caps even after you
are able to use small letters. However, it is a very minor issue - I
mean to say that while all-caps macro names might have made sense long
ago, I do not like it in modern programming.
That has no bearing on my comment.
Are you always so parochial? Is it so hard for you to imagine
that other developers might have different opinions on these
topics?
I think it is pretty clear that when I express an opinion, it is my
opinion - unless you think I have some sort of official status as a
representative for many other programmers. And yes, I fully understand
that opinions vary one topics like this - I am giving you /my/ opinion
and some justification for it. Feel free to ignore it, or give your own
opinions. I certainly value hearing about other ideas, or other
justifications for existing ideas, even if I don't agree with them myself.
The header <stdbool.h> is part of a standard implementation, but
use of <stdbool.h> is optional, not mandatory. Moreover, the
Standard gives explicit and specific permission to undefine the
macros bool, true, and false from <stdbool.h>, so obviously the
Standard anticipates that some developers would want to do that
for one or more of those symbols, and perhaps define their own
versions of these identifiers, even after <stdbool.h> has been
included as a header.
The standard always has to consider compatibility with old code, or with
odd code. <stdbool.h> is optional, and has undefineable macros, in
order to let people work with old code that defines its own bool type
and constants. But it /allows/ this sort of thing - it certainly does
not /recommend/ or /suggest it/. In fact, C11 explicitly says "The
ability to undefine and perhaps then redefine the macros bool, true, and
false is an obsolescent feature" in the section on "Future library
directions".
What I take from this is that you can mess around with your own
definitions of bool, true and false if you have to - but you should not
do so when working on modern and future-proof code.
You're engaging in hyperbole.
Tell that to people who have to maintain code with TRUE (or "true")
defined to 0 or -1, or other such joys. People /have/ written such
code, and telling them that it's a good idea to invent your own versions
of standard types and standard identifiers is a bad idea. The standard
libraries and standard headers are there for a reason, and they should
be used unless you have a very particular reason to do something else
(such as for working with old code).
What I am doing is pointing out
alternate definitions for bool, true, and false, with somewhat
different characteristics for how the identifiers can be used,
that may be preferable in some circumstances. If some
developers find that their own circumstances favor those
different characteristics, they may reasonably prefer to use
those alternate definitions; in other circumstances they may
reasonably prefer to use the <stdbool.h> definitions. The
choice is up to them. Under some circumstances (which I will
not describe), I would advocate using using the <stdbool.h>
definitions; in others I would advocate using the alternate
definitions mentioned above. IMO this question should not be
given a "one size fits all" kind of answer.
I understand what you are saying here. But what we are missing is any
good reasons as to when one would want to use the definitions you
suggest rather than <stdbool.h>. There are occasions why one might need
an odd definition (such as for weird code that defines TRUE to be 0),
but I fail to see any serious advantage of your definition over the
standard one. It's not that I think there is anything /wrong/ with your
enum type - it is just that I see no reason to use it rather than the
standard one.
The idea that bool might or should be an enumerated type has
no bearing on my comments.
I think you have missed the point of what I've been saying. In
any case I cannot be responsible for your lack of imagination.
You /are/ responsible in this case for telling us that there are
"perfectly reasonable" cases where the <stdbool.h> macros would cause
conflicts but your typedef enum version would work, and for telling us
that there are cases where the enum version is significantly better than
the <stdbool.h> version. So either I - and several other posters here -
am lacking imagination, or you are making up justification for your
preferred implementation of bool. Of course, it is absolutely fine for
you to prefer your own implementation - but I would very much like to
hear something more concrete about uses where it makes a real
difference. Unfortunately, with every post in which you fail to give
examples, you re-enforce the thought that you don't have any good
examples. Please prove me wrong here!