While compiling this code:
#include <stdio.h>
enum Boolean
{
TRUE,
FALSE
};
int main(int argc, char **argv)
{
printf("%d", Boolean.TRUE);
return 0;
}
I'm getting:
error: 'Boolean' undeclared (first use in this function)
What I'm doing wrong?
In C, you don't access individually enumerated constants using the syntax EnumType.SpecificEnum. You just say SpecificEnum. For example:
printf("%d", TRUE);
When you write
printf("%d", Boolean.TRUE);
C thinks that you're trying to go to the struct or union named Boolean and access the TRUE field, hence the compiler error.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With