diff options
author | Aaron Crane <arc@cpan.org> | 2017-01-02 15:12:45 +0000 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2017-01-02 21:59:33 +0000 |
commit | b59008ae8ac2856ff5d5730f7019b3e80ae29913 (patch) | |
tree | 3cc00e2f73579c55b57e9276e03a56f36a9b37c1 /pod/perlhacktips.pod | |
parent | 87bac28f3c77a10cf58be33f785c2152ce564ded (diff) | |
download | perl-b59008ae8ac2856ff5d5730f7019b3e80ae29913.tar.gz |
perlhacktips: add some notes on TRUE and FALSE
Diffstat (limited to 'pod/perlhacktips.pod')
-rw-r--r-- | pod/perlhacktips.pod | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pod/perlhacktips.pod b/pod/perlhacktips.pod index 8b3392d361..e12e81c784 100644 --- a/pod/perlhacktips.pod +++ b/pod/perlhacktips.pod @@ -1627,8 +1627,10 @@ bugs in the past. =head2 When is a bool not a bool? On pre-C99 compilers, C<bool> is defined as equivalent to C<char>. -Consequently assignment of any larger type to a C<bool> is unsafe and may -be truncated. The C<cBOOL> macro exists to cast it correctly. +Consequently assignment of any larger type to a C<bool> is unsafe and may be +truncated. The C<cBOOL> macro exists to cast it correctly; you may also find +that using it is shorter and clearer than writing out the equivalent +conditional expression longhand. On those platforms and compilers where C<bool> really is a boolean (C++, C99), it is easy to forget the cast. You can force C<bool> to be a C<char> @@ -1640,6 +1642,10 @@ run C<Configure> with something like or your compiler's equivalent to make it easier to spot any unsafe truncations that show up. +The C<TRUE> and C<FALSE> macros are available for situations where using them +would clarify intent. (But they always just mean the same as the integers 1 and +0 regardless, so using them isn't compulsory.) + =head2 The .i Targets You can expand the macros in a F<foo.c> file by saying |