User forums > Help

Problem compiling code which does work in Borland 3.1

(1/1)

OmnificienT:
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;
}

--- End code ---

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 ===|

--- End code ---

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

Thank you.

killerbot:
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.

Navigation

[0] Message Index

Go to full version