Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User patrickfrei's Avatar
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    438
    Hello

    I noticed that there seems to be a limited number of 12 "if-statements" in a "for-statement". If a add more than 12 "if-statements" the application crashes. My programming structur is as follows:
    Code:
    for (condition)
    {
         if (condition)
         { }
         if (condition)
         { }
         if (condition)
         { }
         ...
    }
    Is that true or could it that there is a potential programming error in that structure??

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    Guess, which is the more probable:
    - a programming language used worldwide by millions of software developers limits the occurences of a specific statement inside a loop
    - you have made an error

  3. #3
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,236
    Hi Patrickfrei,
    Quote Originally Posted by patrickfrei
    Hello

    I noticed that there seems to be a limited number of 12 "if-statements" in a "for-statement". If a add more than 12 "if-statements" the application crashes.
    It should not be a problem.
    There might be something wrong with your code.

    Regards.
    Kirann

  4. #4
    Nokia Developer Champion hotcheese's Avatar
    Join Date
    Jul 2004
    Posts
    2,015
    Quote Originally Posted by wizard_hu_
    Guess, which is the more probable:
    - a programming language used worldwide by millions of software developers limits the occurences of a specific statement inside a loop
    - you have made an error
    Actually, historically there have been quite a lot of defects in the compilers that Symbian has used that have been exposed by code such as this. These were mainly with the gcc compilers.
    They've probably all been discovered and rectified by now, most of them were discovered years ago, but compilers are code too and also therefore can contain defects.

  5. #5
    Registered User dhaas's Avatar
    Join Date
    Sep 2006
    Posts
    9
    I've personally run into problems with gcc in the S60 3rd SDK mis-optimizing. The project worked perfectly before, but after a recompile with "-O2 -fno-unit-at-a-time", the code started crashing the phone when entering a certain very innocuous function. When I put logging statements in to see what was going on, it didn't crash any more...so eventually, it was tracked down that the crash was happening between the line that was "float x;" and "if(bWhatever == true) ...". I'm sure everything in the if statement is perfectly valid C++(not even any particularly exotic code), so that wasn't an issue. What was the solution? Put in between those two lines "int _notused;"

    So the only solution ended up adding a variable never used warning :'(

  6. #6
    Nokia Developer Expert symbianyucca's Avatar
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    28,671
    anyway, with Symbian you shoduln't use this : "if(bWhatever == true)", instead you should use as "if(bWhatever)" only. And I'm quite sure that it is recommended to use EFalse & ETrue definitions with TBool variables, where EFalse is zero and ETrue can be any positive value.

    yucca

  7. #7
    Registered User patrickfrei's Avatar
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    438
    Hmm, I looked through the code again and everything seems to be o.k.!! But after 12 if-statements the application crashes immediately...

    In the if-statements I have code like this:
    Code:
    if (aDescription[ s ].Compare(_L("Manufacturer")) == 0)
    Does someone have an idea for modifying the above code??

  8. #8
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    Why don't you post the exact snippet? Otherwise it's difficult to tell..

  9. #9
    Registered User patrickfrei's Avatar
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    438
    I can't post it because the code is of about 300 lines...

    ...but what I meant is if it makes sense to change the code from:
    Code:
    if (aDescription[ s ].Compare(_L("Manufacturer")) == 0)
    into
    Code:
    if (!aDescription[ s ].Compare(_L("Manufacturer")))
    ...because ==0 is FALSE --> that should not be use according to the posts above --> !

    What do you think?

  10. #10
    Registered User alcoran's Avatar
    Join Date
    Mar 2003
    Posts
    9
    What kind of crash is it? a Panic? which one? does it occurs on device only or with emulator?
    If it's on device only consider that it could be a stack overflow error, which symptom is a kern-exec-3. from what you describe (300 lines function, _L used instead of _LIT..) this is a possibility.

  11. #11
    Registered User patrickfrei's Avatar
    Join Date
    Nov 2006
    Location
    Switzerland
    Posts
    438
    The crash obviously occurs on phone only. I can't tell that with 100% reliability because the information the code displays depends on the HAL information (on the phone there are a lot more information than on the emulator --> i.e. not every if-statement is used on the emulator).

    No message is being displayed on crash. The application simply "disappears"...

    Would you use _LIT instead of _L (even if you use a string only once)??

  12. #12
    Registered User david.caabeiro's Avatar
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678
    You are probably running out of stack memory.. Do this:

    Code:
    _LIT(KManufacturer, "Manufacturer");
    
    if (aDescription[ s ].Compare(KManufacturer) == 0)
    ...

  13. #13
    Registered User vin2ktalks's Avatar
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747
    Quote Originally Posted by patrickfrei
    ...

    No message is being displayed on crash. The application simply "disappears"...

    ...
    As PushL has mentioned use _LIT, but one more thing why can't you create an ErrRd and check the exact reason for the application crash?

Similar Threads

  1. WML & WMLSCript problem ????
    By gemini_shooter in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-14, 06:02
  2. WML & WMLSCript problem ????
    By gemini_shooter in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-14, 06:01
  3. HELP - RCall - Dial voice number crash
    By cmryan in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-02-13, 14:53
  4. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52
  5. Unicode Song Title In NSM Ringtone
    By mcai7db3 in forum Smart Messaging
    Replies: 3
    Last Post: 2002-08-28, 06:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved