"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
If you are doing embedded, it might be a good idea to switch to GCC.
Most embedded compilers are based on GCC, and it does support C99.
Visual Studio gives you better Windows support, but well, you are not coding for Windows.
Because of this. keyword here is 'maybe'.Why not just
typedef char bool;
?
Why use 4 bytes (possibly) when only 1 is required? I never understood why int is used for bools.
Last edited by Bayint Naung; 07-02-2010 at 01:14 AM.
I see only pessimistic optimization.
Actually, I like the bool enum idea:
In normal case, I wouldn't like the idea that it spits out the contents in the global namespace, but this is exactly what is necessary in this case. Plus it defines the type bool.Code:enum bool { false, true };
Why didn't I think of this earlier?
There's just no pleasing some people
> typedef char bool;
> ?
> Why use 4 bytes (possibly) when only 1 is required? I never understood why int is used for bools.
Later....
> Actually, I like the bool enum idea:
enums in C ARE integers.
Incompatibilities Between ISO C and ISO C++
> "'for' loop initial declaration used outside C99 mode" error,
Depending on which version of gcc you end up with, you might need to set it so that you do
gcc -std=c99 prog.c
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.