ETrue Comparison error

Login to reply to this topic.
Fri, 2007-09-14 16:30
Joined: 2007-05-24
Forum posts: 22

Hi Guyes ,

TBool iFlag = EFalse;
if(iFlag == ETrue)

if i compile the above code i dnt get any error ,
If i Build it then i got this error

Undefined symbol: 'int operator==(int, enum TTrue) (??8@YAHHW4TTrue@@@Z)'

I m currently using Carbide.c++ express edition v1.2.2 Build 5

I Know there is alternate solution available for this code , like ...if(iFlag)
But i want to figure out what `s problem here ,


Fri, 2007-09-14 16:34
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Re: ETrue Comparison error

You should not test boolean against ETrue or EFalse but use the following:

TBool iFlag = EFalse;
if(iFlag)
{ 
    .... Do something if iFlag is ETrue ...
}

if(!iFlag)
{
     .... Do something if iFlag is EFalse...
}


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2007-09-14 16:36
Joined: 2007-05-24
Forum posts: 22
Re: ETrue Comparison error

Thnxs 4 ur Immediate reaply eric

But i want to figure out what problem in my code

Sorry ........ I m novice

Fri, 2007-09-14 17:21
Joined: 2005-11-20
Forum posts: 1241
Re: ETrue Comparison error

TBool is defined in E32DEF.H as

typedef int TBool;

but ETrue and EFalse, a bit strangely, in E32STD.H as

enum TFalse {EFalse=FALSE};
enum TTrue {ETrue=TRUE};

Now, if you want to compare with == an int and a value of an enumeration type, a special operator overload must be present. It isn't, that's why your code does not compile.


René Brunner

Fri, 2007-09-14 19:38
Joined: 2004-07-10
Forum posts: 364
Re: ETrue Comparison error

I think the it might be designed deliberatly that it generates a compilation error

Sat, 2007-09-15 04:43
Joined: 2007-05-24
Forum posts: 22
Re: ETrue Comparison error

Thanks , 4 Ur replay

Mr René Brunner
I m agree with U , Opertaor (==)is not defined .

Mr Buttington

" I think the it might be designed deliberatly that it generates a compilation error "

I m also agree with Ur comment ,

  • Login to reply to this topic.