Time to standardize "true" and "false"

John Nagle nagle at well.UUCP
Fri Sep 22 03:59:57 AEST 1989


     I would like to suggest that the time has come to standardize the
Boolean values in C.  Most programs have definitions of these, but they
differ and clash.  As the typing rules become ever tighter, and the number
of commercial libraries available grows, this becomes a more and more
serious problem.  Commercially published libraries have spellings such
as "TRUE", "true", and "True", forms of definition including "#define",
"const", and "enum", and Boolean types (spelled variously) defined
as "char", "unsigned char", "unsigned short", and "enum".

     This has got to stop.

     I would suggest that the standardized definition be

	const boolean (false=0, true=1);

which follows the convention that predefined types in C are all lower
case.  The explicit values for "false" and "true" are given, although
redundant, to make the point that those values are part of the specification
and are not an accident of the ordering in the definition. 

     It should be mandated that this definition be a part of the C
and C++ header files, preferably in an ANSI-specified file.
"stddef.h" seems a likely choice, but this is open to discussion.

     If it's too late to fix this in C, it should be fixed in C++, where
typing is taken more seriously.

					John Nagle



More information about the Comp.lang.c mailing list