Author: Omid David Tabibi
Date: 04:50:43 09/26/03
Go up one level in this thread
On September 26, 2003 at 07:32:47, Vincent Diepeveen wrote: >On September 26, 2003 at 06:50:59, Gerd Isenberg wrote: > >>Hi All, > >current compilers do not recognize bool in C. > >whether it's in ansi-c 99 i would not be amazed, but before that it for sure >wasn't. _Bool was introduced in C 99. ANSI C doesn't have any boolean type. > >>in C++ we have the boolean type "bool" with the value range true/false. >>I'm not sure about ANSI-C. >> >>Due to some C-related "portability" problems and possible performance drawbacks >>due sizeof(bool) == 1 implies partial register handling or zero extending to >>native word lenght, you find in most MS-sources an "own" boolean type BOOL: >> >>typedef int BOOL; // e.g. WINDEF.H >> >>This own BOOL type is of course not "typesafe" as bool, as you may assign any >>"int" expressions to it. With BOOL one should interprete zero as FALSE and any >>other value as TRUE. Due to this ambiguity, comparing BOOL-expressions with TRUE >>may be erroneous, so better compare with != FALSE. >> >>See also this bugreport related to this issue: >> >>http://www.codeproject.com/buglist/virtualboolbug.asp >> >>Actually i have some "disputes" with colleagues obout it. >>I found bool better for didactical reasons, >>but stay with BOOL for pragmatical reasons. >> >>A few questions: >> >>Is sizeof(bool) == 1 per definition, >>or is it compiler implementation depending? >> >>Is there any conditional preprocessor directive to ask whether a user defined >>type is already typedefined, similar to #ifdef? >> >>What is your opinion / experience with bool versus BOOL? >> >>Thanks in advance for your suggestions, >>Gerd
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.