Hi, I keep getting an undefined identifier error when I try to do this:

typedef char bool; // Make a bool type
char false = 0, true = 1; // Make true and false

void foo()
{
switch (something)
{
case 1:
bool aaaaa;
break;
}
}

It only gives me an error it if i try to declare it in a case. Please help :P

Recommended Answers

All 7 Replies

what is the error that you are getting?...

In Dev-C++ 4.9.9.2:
`bool' undeclared (first use in this function)

(Each undeclared identifier is reported only once for each function it appears in.)

Try this...

switch(){
   case 1: 
               ;bool aaaa;
               break;
   ...
   ...
}

This will not give any error...

Consider also

case 1:
      {
         bool aaaaa;
      }
      break;

Thanks! That works perfectly! :)

Please mark the thread as solved...
Thank You...

Just some literature from wikipedia:
"In C99, there is a bool type, along with the values true and false, defined in the <stdbool.h>"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.