×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Significance Of Compiler Warnings

    Dear Symbian Experts,

    I need your knowledgeable comments about the compiler warnings.

    I think that the source code should be free from compiler warnings.
    I am investigating some third party source code to be used in my project.
    I am evaluating the source code and trying to do its performance tuning.
    Its a very big and complex source code .

    While building the source code i am getting compiler warnings in many modules.
    I am mentioning examples of some warnings that i am facing and threats that can be encountered because of them , kindly correct me and suggest me..

    1) Warning : variable / argument 'aXYZ' is not used in function
    XYZ.cpp line XYZ

    i feel that if these arguments are not used or required in thde function , should i remove them or not ?

    i guess that unnecessary function arguments/parameters are needlessly consuming the call stack memory , kindly suggest ?

    2) Parameter mismatch case. implicit typecast by compiler issue.

    for example ,

    i have a function that takes TInt32 as parameter and i am passing a TInt64 value to this function. i have not seen any warning from compiler in this case . but it can be dangerous because 32 bits of data may be lost in this scenario .

    eg.

    void test(TInt32 x)
    {
    // x=5;
    }
    void test1()
    {

    TInt64 abc=40000000000;
    test(abc);
    }

    i get only one warning here that 'x' is not used in function test().

    is there any way to catch these type of scenarios ,
    if there any warning settings for compiler.

    i am using CodeWarrior 3.1.1.


    I will add more warning issues/scenarios later.

    thanks for reading my message.
    Last edited by navjotsingh1979; 2007-10-09 at 07:23. Reason: spelling check

  2. #2
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: Significance Of Compiler Warnings

    Hi
    1) Warning : variable / argument 'aXYZ' is not used in function
    XYZ.cpp line XYZ

    i feel that if these arguments are not used or required in thde function , should i remove them or not ?

    i guess that unnecessary function arguments/parameters are needlessly consuming the call stack memory , kindly suggest ?
    You can remove the arguments safely if it is not used..



    2) Parameter mismatch case. implicit typecast by compiler issue.

    for example ,

    i have a function that takes TInt32 as parameter and i am passing a TInt64 value to this function. i have not seen any warning from compiler in this case . but it can be dangerous because 32 bits of data may be lost in this scenario .

    eg.

    void test(TInt32 x)
    {
    // x=5;
    }
    void test1()
    {

    TInt64 abc=40000000000;
    test(abc);
    }
    The typecast should be done while manipulating the bits operations,otherwise it will take default of 32bit itself instead of 64 bits that you trying to use..

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  3. #3
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Re: Significance Of Compiler Warnings

    Thanks mateen_maldar.

    Regarding point 2 in discussion,

    i just gave you a simple example of function parameter mismatch .

    there can be many mismatches like this inside a third party source code..

    do u think any efficient , fast and logical way of catching such cases in source code..

    any idea about compiler warning settings with Codewarrior 3.1.1.

    thanks again,
    nEo

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Significance Of Compiler Warnings

    You should be able to change the compiler settings to warn you on all implicit casts that would cause a problem (like the one you give an example of). Unfotunately I don't know how to do this in codewarrior. Perhaps someone else who still uses codewarrior can help?

    In your specific example though, the parameter not being used means that the implicit cast is irrelevant - it won't have any effect.

    You can usually remove unused arguments. As you say they do waste memory on the stack (and also some code size can be saved). However, in some cases the unused argument could be in a function that is implementing an interface and just happens not to need the argument. In that case it is usually much simpler to leave it in place.

    Sorcery

  5. #5
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Significance Of Compiler Warnings

    I think a better option is commenting out the unused argument instead (unless you're passing a big object by value, which you shouldn't be doing in any case). You could be dealing with an interface implementation that doesn't need a specific argument, to give an example.

    Regarding enabling cw warnings, just browse the manual, or use -h

  6. #6
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Re: Significance Of Compiler Warnings

    thanks to all,
    but can anybody tell me how to enable implicit compiler conversion warnings with code warrior 3.1.1

    thanks
    nEo

  7. #7
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Significance Of Compiler Warnings

    I don't have CW at hand right now, but you do. Just run the compiler from the command line and see the options available. It isn't that hard to do, and will give you the info you need.

    After knowing the options, you can even include them in the mmp:

    Code:
    OPTION CW -yourspecialwarningoption

  8. #8
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Question Re: Significance Of Compiler Warnings

    Quote Originally Posted by PushL View Post
    I don't have CW at hand right now, but you do. Just run the compiler from the command line and see the options available. It isn't that hard to do, and will give you the info you need.

    After knowing the options, you can even include them in the mmp:

    Code:
    OPTION CW -yourspecialwarningoption
    what are all possible available values for parameter 'yourspecialwarningoption' ?

  9. #9
    Regular Contributor
    Join Date
    Oct 2004
    Location
    Tokyo,Japan
    Posts
    289

    Thumbs up Re: Significance Of Compiler Warnings

    dear experts,

    consider this scenario.

    void test(MyClass aMyObject)
    {
    return XYZ;
    }

    here in function test() , the parameter aMyObject is not used and compiler will warn about this.

    now if i change above function in this way , by commenting out parameter name

    void test(MyClass /*aMyObject*/)
    {
    return XYZ;
    }


    will this method make any effect on call stack size ,

    or i should simple change my function test() as follows...

    void test()
    {
    return XYZ;
    }

    thanks,
    nEo

  10. #10
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: Significance Of Compiler Warnings

    If you call a function then the arguments will usually be stored in the CPU registers. If that function returns without calling another function then they never get pushed onto the stack. So in your example it doesn't use any more stack if the variable is included or not.

    If you do call another function inside your function then usually the arguments to the first function call are saved to the stack from the registers and arguments for the new function stored in the original registers (this is a bit simplified and is compiler and optimisation setting dependent).

    So as a general answer to your question - if there is no argument passed into a function then there's nothing to be pushed to the stack, therefore, no more memory used.

    Hope that helps,
    Sorcery

Similar Threads

  1. error: Couldn't find compiler "Symbian Compiler v2"
    By zapotek in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2007-03-07, 18:45
  2. EABI Compiler
    By jascco in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2006-12-07, 10:33
  3. Compilation errors and warnings on Nokia series 60 3rd Edition
    By chitransh_chetan in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 3
    Last Post: 2006-04-17, 21:39
  4. GCCE compile warnings using S60 3rd ed SDK
    By RyanSantos in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2006-02-22, 02:45
  5. compiler bug, using Metrowerks front end
    By maambach in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-12-02, 14:47

Posting Permissions

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