A
Alex Vinokur
I came across the following piece of code:
#define ERROR -1
#define STATUS0 0
#define STATUS1 1
#define STATUS2 2
unsigned char foo()
{
if (/* condition-A */) return ERROR; /* is that safe? */
if (/* condition-B */) return STATUS0;
if (/* condition-C */) return STATUS1;
return STATUS2;
}
Is '-1 returned as unsigned char' safe in the given context?
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
#define ERROR -1
#define STATUS0 0
#define STATUS1 1
#define STATUS2 2
unsigned char foo()
{
if (/* condition-A */) return ERROR; /* is that safe? */
if (/* condition-B */) return STATUS0;
if (/* condition-C */) return STATUS1;
return STATUS2;
}
Is '-1 returned as unsigned char' safe in the given context?
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn