×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    14

    Thumbs down S60 3rd edition linker problem

    Hi,

    Time for another newbie question.

    All of a sudden our project has started to get linker problems, in both the emulator and the GCCE build.

    The linker error we get is
    int operator==(int, enum TTrue)
    And an example of code that creates the "error"
    Code:
    void MyClass::MyMethod( void )
    {
        TBool myBool = ETrue;
    
        if( myBool == ETrue ) //Linker problem line of code
        {
            //Do something
        }
    }
    Do get it through the linker, it's just to cast the ETrue to a TBool before comparing, like below
    Code:
    void MyClass::MyMethod( void )
    {
        TBool myBool = ETrue;
    
        if( myBool == (TBool)ETrue )
        {
            //Do something
        }
    }
    But should it really be necessary?

    Regards,
    ddskani

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: S60 3rd edition linker problem

    Its not good 'style' to do comparison on a boolean.

    You could simply rewrite your code as

    ...
    if( myBool )
    ....

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Austin, TX, USA
    Posts
    52

    Re: S60 3rd edition linker problem

    excellent-and-concise post as usual hotcheese.

    i would add that this is caused by, in your case, ddskani, the TBool being typedef'd to an int, (usually the case depending on compiler) while ETrue is an enum which means you're comparing 2 different things. Mixing these 2 is not great but permitted in certain cases -- I'd have to re-read the latest C++ specs about that case in particular but I'm guessing that the latest specs are causing the compiler writers to handle the case differently than before.

    If you can change the code, go for it.

    If you can't change the code now, because 1) practically it's in zillions of places and you need to compile today to get the product out the door until you have time to rewrite it everywhere per hotcheese or 2) it's in 3rd-party code (aside: i've seen variants of this in 'system' code provided by 'company name withheld ' ) here's some possible interim solutions off the top of my head -- they have pros and cons so you weigh the decision based on your needs: some compilers have options allowing you to control this behavior; alternatively you can provide a quick implementation of the == method yourself.....

    Good luck!
    Last edited by regan_coleman; 2006-09-02 at 13:16.
    regan_coleman AT xenient.com

  4. #4
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: S60 3rd edition linker problem

    That linker error is actually a useful thing.

    If you had some code such as

    myBool = ETrue;

    But mistyped it as
    myBool == ETrue;

    Then without the linker error you'll have a bug that could take a while to track down.

  5. #5
    Nokia Developer Expert
    Join Date
    Jul 2003
    Location
    Vancouver, Canada
    Posts
    220

    Re: S60 3rd edition linker problem

    more info can be found here http://www.symbian.com/developer/tec...uide%2eboleean

    I remember being told way back in 1998 on a EPOCWorld Training course that the reason EFalse and ETrue are declared as such is to create the linker problem and stop people misunderstanding which value is true/false for boolean.

    more discussion about pros and cons of bool can be found here http://www.glenmccl.com/bool_cmp.htm

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Austin, TX, USA
    Posts
    52

    Re: S60 3rd edition linker problem

    >>That linker error is actually a useful thing.
    ...
    >>I remember being told way back in 1998 on a EPOCWorld Training course that the reason EFalse and ETrue are declared as such is to create the linker problem and stop people misunderstanding which value is true/false for boolean.

    Yep. See : http://www3.symbian.com/faq.nsf/0/FF...4?OpenDocument
    regan_coleman AT xenient.com

Similar Threads

  1. Replies: 35
    Last Post: 2009-04-11, 14:36
  2. OpenGL ES on S60 3rd Edition SDK Emulator
    By specjones in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2008-09-30, 10:22
  3. Problem of running video clip (in 3gp formate) on S60 3rd edition SDK
    By AWAIS_CIIT in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2007-07-31, 10:18
  4. S60 3rd edition, WSDL, WebServices anyone?
    By myohol in forum Symbian Tools & SDKs
    Replies: 21
    Last Post: 2007-06-25, 09:57
  5. TTime : TInt64& Int64() problem in S60 3rd edition
    By iulian_moldovan in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2006-01-24, 13:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×