Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!husc6!harvard!caip!seismo!brl-sem!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <412@brl-smoke.ARPA> Date: Wed, 30-Apr-86 07:43:01 EDT Article-I.D.: brl-smok.412 Posted: Wed Apr 30 07:43:01 1986 Date-Received: Sun, 4-May-86 05:34:47 EDT References: <838@ihwpt.UUCP> Reply-To: gwyn@brl.ARPA Distribution: net Organization: Ballistic Research Lab (BRL) Lines: 27 In article <838@ihwpt.UUCP> knudsen@ihwpt.UUCP (mike knudsen) writes: >Has anyone else noticed that Boolean types and operators >have less than full citizenship in C? Examples: >... >(3) There is no boolean data type. No big gripe; >lots of us say "typedef short bool" in our .h files. Technically, there are no true Boolean data types in C. Ints (NOT shorts) are made to serve when a Boolean would be called for. I have always considered this a deficiency, but (except for getting "lint" to cooperate) it can be remedied by the programmer being careful to keep Boolean usages distinct from integer usages. For example, treat the result of a relational expression as Boolean, not as a 1 or a 0. I find that carefully maintaining the distinction contributes to code correctness and maintainability. I generally frown on C language extension via the preprocessor (as in a recent Byte article), but I make an exception for Booleans. The same standard header file that I mentioned a few days ago (that defines "void" for machines that don't have it, etc.) contains the following: typedef int bool; /* boolean data */ #define false 0 #define true 1