Click here to Skip to main content
14,492,955 members

C / C++ / MFC

 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_21-Feb-20 10:18
MemberVaclav_21-Feb-20 10:18 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 10:51
Memberk505421-Feb-20 10:51 
AnswerRe: To bool or not to bool in C/C++ ? Pin
Stefan_Lang21-Feb-20 0:31
mveStefan_Lang21-Feb-20 0:31 
AnswerRe: To bool or not to bool in C/C++ ? Pin
Vaclav_21-Feb-20 5:30
MemberVaclav_21-Feb-20 5:30 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan21-Feb-20 5:54
mveRichard MacCutchan21-Feb-20 5:54 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_21-Feb-20 8:29
MemberVaclav_21-Feb-20 8:29 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan21-Feb-20 22:03
mveRichard MacCutchan21-Feb-20 22:03 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 5:56
Memberk505421-Feb-20 5:56 
Vaclav_ wrote:
C still has no standard ( AKA what used to be defined in " ANSI C standard " ) "type" bool

Wrong. As of C99 (1999! 30+ Years ago!), the standard defined _Bool, and include <stdbool.h> which includes the macros
#define bool    _Bool
#define true    1
#define false   0
In fact, in the comments to stdbool.h on my system I see
/*
 * ISO C Standard:  7.16  Boolean type and values  <stdbool.h>
 */
Vaclav_ wrote:
C++ has "type" bool but evaluates to something called "true " or "false" which in reality is "something / application/ os " or whatever dependent and hides the binary value of these symbols. Hence no "standard" in sense of "ANSI C standard " again

Wrong again. The standard defines "true" and "false" as 0 and 1. Unless you use std::boolalpha, you normally get 0 or 1 when printing to an iostream (std::cout, etc).

Technically I think that the implementation is free to use whatever values "behind the scenes" to implement a bool, but its representation is as if it had a value of 0 and 1. The same is true for NULL. A given implementation may use any value it wishes to indicate a NULL pointer, but it has to act like a zero in certain contexts. I believe this was the case in the days when we had NEAR and FAR pointers. All the bits of a FAR NULL pointer might not be zero, as its segment selector might be set, but it would compare equal to zero, and equal to any other FAR NULL which had a different segment selector.

modified 21-Feb-20 12:03pm.

GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan21-Feb-20 6:07
mveRichard MacCutchan21-Feb-20 6:07 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 6:16
Memberk505421-Feb-20 6:16 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan21-Feb-20 6:18
mveRichard MacCutchan21-Feb-20 6:18 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_21-Feb-20 8:25
MemberVaclav_21-Feb-20 8:25 
GeneralRe: To bool or not to bool in C/C++ ? Pin
k505421-Feb-20 9:31
Memberk505421-Feb-20 9:31 
AnswerRe: To bool or not to bool in C/C++ ? Pin
leon de boer21-Feb-20 11:55
Memberleon de boer21-Feb-20 11:55 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Vaclav_22-Feb-20 5:34
MemberVaclav_22-Feb-20 5:34 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan22-Feb-20 6:47
mveRichard MacCutchan22-Feb-20 6:47 
GeneralRe: To bool or not to bool in C/C++ ? Pin
leon de boer23-Feb-20 5:29
Memberleon de boer23-Feb-20 5:29 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Richard MacCutchan23-Feb-20 6:08
mveRichard MacCutchan23-Feb-20 6:08 
GeneralRe: To bool or not to bool in C/C++ ? Pin
Victor Nijegorodov23-Feb-20 20:43
MemberVictor Nijegorodov23-Feb-20 20:43 
GeneralText based mining game using if and while Pin
Chleba22519-Feb-20 10:41
MemberChleba22519-Feb-20 10:41 
GeneralRe: Text based mining game using if and while Pin
Stefan_Lang19-Feb-20 21:42
mveStefan_Lang19-Feb-20 21:42 
GeneralRe: Text based mining game using if and while Pin
Vaclav_20-Feb-20 17:04
MemberVaclav_20-Feb-20 17:04 
GeneralRe: Text based mining game using if and while Pin
Chleba22521-Feb-20 20:32
MemberChleba22521-Feb-20 20:32 
SuggestionRe: Text based mining game using if and while Pin
David Crow24-Feb-20 3:44
MemberDavid Crow24-Feb-20 3:44 
QuestionCannot open file 'hid.lib' in microsip Pin
Jafar_Ulla19-Feb-20 2:14
professionalJafar_Ulla19-Feb-20 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.