Author Topic: Problem compiling code which does work in Borland 3.1  (Read 3281 times)

Offline OmnificienT

  • Single posting newcomer
  • *
  • Posts: 5
Problem compiling code which does work in Borland 3.1
« on: November 12, 2009, 08:34:20 pm »
Hello,

I can't seem to compile the following using code::blocks
Code
#include <stdio.h>

int main(void)
{
    enum BOOL {true, false};
    enum BOOL bFlag;

    if (bFlag == true) printf("TRUE");
    return 0;
}

It will give me this output:

Code
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c||In function `int main()':|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|5|error: expected identifier before "true"|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|5|error: expected `}' before "true"|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|5|error: expected unqualified-id before "true"|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|6|error: use of enum `BOOL' without previous declaration|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|6|error: invalid type in declaration before ';' token|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|8|error: expected unqualified-id before "if"|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|9|error: expected unqualified-id before "return"|
C:\Documents and Settings\Pim\Mijn documenten\C\enumtest.c|10|error: expected declaration before '}' token|
||=== Build finished: 8 errors, 0 warnings ===|

However, in Borland 3.1 it works just fine. Does anyone know what is going on?

Thank you.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Problem compiling code which does work in Borland 3.1
« Reply #1 on: November 12, 2009, 08:45:14 pm »
first of all, C or C++.

In case of C++, there you have bool, with values true/false :-)

So I assume you are doing C ?
Try to define your enum with a typedef, or try to use _Bool.