diff options
| author | rillig <rillig@NetBSD.org> | 2020-09-02 23:42:58 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2020-09-02 23:42:58 +0000 |
| commit | bffe4909419d70be0aebbd5f489a67ae3cd6ae09 (patch) | |
| tree | 81afde535850b7c4508bbbadbed5d24de9cf1e09 /usr.bin/make | |
| parent | 313d8afd3b504ee74b9bbf64ad3abd2ae17ac4c8 (diff) | |
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.
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/make.h | 8 |
1 files changed, 5 insertions, 3 deletions
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 |
