News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Problem compiling code which does work in Borland 3.1

Started by OmnificienT, November 12, 2009, 08:34:20 PM

Previous topic - Next topic

OmnificienT

Hello,

I can't seem to compile the following using code::blocks

#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:


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.

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.