Is there any downside to using
typedef char bool;
enum boolean { false, true };
in C to provide a semantic boolean type?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C99, you should be using
stdbool.h, which definesbool,true, andfalse.Otherwise what you have is fine. Using just the enum may be a bit simpler, but if you really want to save space what you have works.