Thread: LCC Compiler odd warning

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688

    LCC Compiler odd warning

    Hey guys!

    I recently updated code::blocks to the new version for my home laptop and I always compile using the LCC compiler.

    Before the upgrade - this:

    Code:
    //....
    int main(int argv, char* argc[])
    {
    }
    Gave me this:

    Code:
    ||=== Build finished: 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
    Output from Dir: $C://AdaSkylaRose/C/demo.c
    However, the exact same definition of function main after the upgrade gave me this:

    Code:
    ||=== Build finished: 0 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|
    Output from Dir: $C://AdaSkylaRose/C/demo.c
    main.c|15|parameter 'pointer to pointer to char argc' is not referenced|
    main.c|15|parameter 'int argv' is not referenced|
    main.c|15|definition of function main is non C11 standard
    I have never seen these warnings before. I do not know if the reason is the updating of code::blocks has forced the LCC compiler to update with it (thus implementing the new standard?) but if I change it to simply:

    Code:
    int main(void)
    It compiles fine with no warnings. Anyone know or seen this before?

    Ada x
    Double Helix STL

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > int main(int argv, char* argc[])
    The traditional names are argc and argv
    Swapping them over is just weird.

    Also, the warning about parameters being unused is to help writing clearer code.
    - perhaps you forgot to use the parameter, and you need to keep editing.
    - perhaps you never needed the parameter, so it's best to remove it altogether.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Thanks Salem.

    I swapped the 'c' and 'v' around and will keep to that format from now on. I still do not understand why I am getting "unused" warnings about the parameters of the main function - maybe it's going to be part of the standard in C to have main written as

    Code:
    int main(void)
    That's just a random guess, and I do understand what it means by the warnings it's just the one about the C standard totally threw me.

    Ada x
    Double Helix STL

  4. #4
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    argc means "argument count".
    argv means "argument vector".
    Since you're not using those variables, you get a warning.
    The same thing would happen if you defined "int n;" in the body of main and didn't use it.
    It should have been warning you about it all along.
    Probably all that changed is the default warning level.
    If you aren't using them then you shouldn't define them.

  5. #5
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Thank you algorism. I really appreciate your input on the subject .

    Oddly, I generally got the unused warning if for example if I declared but did not use a variable as you stated, just never about the parameters in function main. Anyways - thank you for your help and from now on I'll just define main as returning int with a void parameter list.
    Double Helix STL

  6. #6
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    That's interesting, and I'm not familiar with the LCC compiler so warnings and warning levels, etc., can differ.

    Parameters are really just local variables that are initialised by the function call, so they should probably be treated the same way. Perhaps in a recent update they decided to start warning about the parameters the same way as the other local variables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler warning
    By Madhavi in forum C Programming
    Replies: 8
    Last Post: 06-09-2016, 10:46 AM
  2. gcc compiler warning
    By matrixx333 in forum C Programming
    Replies: 4
    Last Post: 07-14-2010, 04:43 AM
  3. Compiler Warning
    By samuelmoneill in forum C Programming
    Replies: 5
    Last Post: 04-16-2009, 06:57 AM
  4. compiler warning still won't go away
    By trprince in forum C Programming
    Replies: 1
    Last Post: 11-30-2007, 08:35 PM
  5. Why compiler warning?
    By cdave in forum C Programming
    Replies: 16
    Last Post: 09-06-2004, 01:03 AM

Tags for this Thread