bool

Objective C - access BOOL ivar of void pointer to self

I have a thing that uses a SystemSoundID to play a sound, and then repeat with a C function being used as the sound completion callback, and the function is passed (void *)self (since it has to be a void pointer), and then I want to play the sound again if the alarmPlaying BOOL ivar of self is true, otherwise remove the sound completion ...

Is bool a native C type?

I've noticed that the Linux kernel code uses bool, but I thought that bool was a C++ type. Is bool a standard C extension (e.g., ISO C90) or a GCC extension? ...

Where is stdbool.h?

I want to find the _Bool definition on my system, so for systems where it's missing I can implement it. I've seen various definitions for it here and on other sites, but wanted to check on the system for the definitive definition. Slight problem, in that I can't find where _Bool is defined or even stdbool.h mussys@debmus:~$ find /usr/i...

C++ implicit conversion to bool

In an effort to make my enums more typesafe, I've been using macro-generated overloaded operators to disallow comparing enums against anything but an identically typed enum: #include <boost/static_assert.hpp> #define MAKE_ENUM_OPERATOR_TYPESAFE(enumtype, op) \ template<typename T> \ inline bool operator op(enumtype lhs, T rhs) \ ...

C# bool expression evaluation order

Possible Duplicate: == Operator and operands Possible Duplicates: Is there any difference between if(a==5) or if(5==a) in C#? == Operator and operands Ok, this may be stupid question, but searching in google (cant seem to ACTUALLY search for an exact phrase even with quotes) What if any difference is there between i...

C++ bool array as bitfield?

Hi! let's say i need to store 8 bools in a struct, but i want to use for them only 1 byte together, then i could do something like this: struct myStruct { bool b1:1; bool b2:1; bool b3:1; bool b4:1; bool b5:1; bool b6:1; bool b7:1; bool b8:1; }; and with this i could do things like myStruct asdf; asd...

C++ from C#: C++ function (in a DLL) returning false, but C# thinks it's true!

Hi everyone, I'm writing a little C# app that calls a few functions in a C++ API. I have the C++ code building into a DLL, and the C# code calls the API using DllImport. (I am using a .DEF file for the C++ DLL so I don't need extern "C".) So far the API has one function, which currently does absolutely nothing: bool Foo() { return f...

Windows: How big is a BOOL?

How big (in bits) is a Windows BOOL data type? Microsoft defines the BOOL data type as: BOOL Boolean variable (should be TRUE or FALSE). This type is declared in WinDef.h as follows: typedef int BOOL; Which converts my question into: How big (in bits) is an int data type? Edit: In before K&R. Edit 2: Somethi...

Convention result and code error C++ int foo (...)

In Linux for example when i use batch if error code is 0 thats good, but what is the convention in C++ ? when int (or bool) is equal to one we say that's true, but what must be the return of such function in C++ ? ...

can C# enums be declared as of bool type?

Hi, Can I declare c# enum as bool like: enum Result : bool { pass = true, fail = false } ...

comparing BOOL against YES

I found today a comment in a source file: // - no longer compare BOOL against YES (dangerous!) So my question is: Is comparing BOOL against YES in Objective-C really that dangerous? And why is that? (Can the value of YES change during runtime? Like NO is always 0 but YES can be 1, 2 or 3 - depending on runtime, compiler, your linke...

Objective-C dictionary inserting a BOOL

OK, I'm a little confused. It's probably just a triviality. I've got a function which looks something like this: - (void)getNumbersForNews:(BOOL)news andMails:(BOOL)mails { NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init]; [parameters setValue:news forKey:@"getNews"]; [parameters setValue:mails forKey:@"getMails"]...

Validate a bool that must be true using xVal

I have a business requirement to enforce a check box on a HTML form to be marked as true before allowing submission of the form. I can return the user to the form if this box has not been checked with an appropriate message, but want to return all information from an xVal validation of the form data at the same time. I can't find any i...

Converting from a std::string to bool

What is the best way to convert a std::string to bool? I am calling a function that returns either "0" or "1", and I need a clean solution for turning this into a boolean value. ...

Why I can't extend bool in Python?

>>> class BOOL(bool): ... print "why?" ... why? Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Error when calling the metaclass bases type 'bool' is not an acceptable base type I thought Python trusted the programmer. ...

Can two booleans be compared in C++?

Is the following piece of code supposed to work? bool b1 = true; bool b2 = 1 < 2; if (b1 == b2) { // do something } I suspect that not all 'trues' are equal. ...

Help with c# and bool on asp.net mvc

Whats the best way to print out "Yes" or "No" depending on a value In my view I want to print out Model.isStudent and I dont want True or False, I want Yes or No.... do I Have to write if else statement? ...

What is the use of Nullable<bool> type?

a bool variable could hold true or false, while bool? could be null as well. Why would we need a third value for bool ? If it is not true, what ever it is, it is == false Can you suggest a scenario where I would fancy a bool? instead. Thanks ...

bool function problem - always returns true ?

#include <iostream> #include <string> #include <algorithm> #include <cstdlib> #include <cstdio> using namespace std; static bool isanagram(string a, string b); int main(void) { int i,n,j,s; cin >> n; string a, b; cin >> a >> b; if(!isanagram(a,b)) cout << "False" << endl; else cout << "True" << endl; return...

Is BOOL read/write atomic in Objective C?

What happens when two threads set a BOOL to YES "at the same time"? ...