Thread (2 messages) 2 messages, 2 authors, 2015-01-08

ternary vs double exclamation

From: John de la Garza <hidden>
Date: 2015-01-08 04:58:03

Possibly related (same subject, not in this thread)

On Sun, Jan 04, 2015 at 08:17:15PM -0500, Valdis.Kletnieks at vt.edu wrote:
On Sun, 04 Jan 2015 18:43:22 -0500, John de la Garza said:
quoted
On Sat, Jan 03, 2015 at 11:20:29PM -0500, Valdis.Kletnieks at vt.edu wrote:
quoted
On Sat, 03 Jan 2015 18:54:00 -0500, John de la Garza said:
quoted
It should not be assumed that true will always be 1 as defined in
include/linux/stddef.h, right?
No, I mean use an actual 'bool' type rather than 'int'.  Consider this from
kernel/softirq.c:
yes, bool has two possible values true and false

from include/linux/stddef.h:
enum {
	        false   = 0,
		true	= 1
};
Note that's an *anonynous* enum, which defines the two values, but
it *doesn't* define an enum type that can be used to force type safety.

No, if you're converting a variable from int to bool, the *important* line is
from include/linux/types.h:

typedef _Bool                   bool;

which ensures more type safety than the enum does.
right, I see that now

so _Bool is a defined by the compiler and typedefed to bool 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help