-
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:
It compiles fine with no warnings. Anyone know or seen this before?
Ada x
-
> 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.
-
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
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
-
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.
-
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.
-
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.