From bffe4909419d70be0aebbd5f489a67ae3cd6ae09 Mon Sep 17 00:00:00 2001 From: rillig Date: Wed, 2 Sep 2020 23:42:58 +0000 Subject: make(1): document the value restrictions for Boolean variables The previous lenient rule came from the sprite.h header that was not specific to make. To avoid confusion, only the expected values should be stored in a Boolean variable. To help find obvious violations and inconsistencies, there are different possibilities for the Boolean type, during development. In C there is no way to actually enforce this restriction at runtime. It would be possible in C++, but the code is not ready to be compiled with a C++ compiler. --- usr.bin/make/make.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.bin/make/make.h') diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index 3d0b1631962..6191d75829a 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.136 2020/09/02 04:08:54 rillig Exp $ */ +/* $NetBSD: make.h,v 1.137 2020/09/02 23:42:58 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -130,8 +130,8 @@ #endif /* - * A boolean type is defined as an integer, not an enum. This allows a - * boolean argument to be an expression that isn't strictly 0 or 1 valued. + * A boolean type is defined as an integer, not an enum, for historic reasons. + * The only allowed values are the constants TRUE and FALSE (1 and 0). */ #ifdef USE_DOUBLE_BOOLEAN @@ -143,6 +143,8 @@ typedef double Boolean; typedef unsigned char Boolean; #define TRUE ((unsigned char)0xFF) #define FALSE ((unsigned char)0x00) +#elif defined(USE_ENUM_BOOLEAN) +typedef enum { FALSE, TRUE} Boolean; #else typedef int Boolean; #endif -- cgit