Stefan Lucke wrote: > On Sonntag 07 Mai 2006 19:47, Denis Oliver Kropp wrote: > >> Stefan Lucke wrote: >> >> But also looks more "heavy". Something very short might clash easily, >> e.g. the underscore is already taken :) >> >> With stdbool.h you don't have to take care of that IIRC. >> >> What about using an enum again, but not using the reserved name >> for it? What about b00l, DBool, dbool, Dbool, DirectBool or boolean? >> > That leads to general programming styles/guides. > Why redefining standard types ? > > As I'm an old fashioned C programmer, 0 evaluates to " false" and any other > value to "true". So any local or somewhere else defined type of bool(EAN) > may lead to troubles (typedef int MyBool; ). > But if space sizeof(char) vs. sizeof(int) makes a difference .. . >
Although char is smaller than int, on CPUs which have int as the native register size, using int is faster as no masking is required. To justify using char there must be a really good reason that there is no other way to work around. (If there is just one or a few arrays or similar where the size of a boolean matters then it might be better to use a special type in just these cases and stick to the normal int sized boolean for all other cases.) I could not agree more to the definition that 0 is false and anything else is true. I often have to remind people not to compare against arbitrary values of "true". Regards, James. _______________________________________________ directfb-dev mailing list [email protected] http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev
