|
|
Home » U++ Library support » U++ Core » Problem with gcc compilers and -Wall
Problem with gcc compilers and -Wall [message #28589] |
Wed, 08 September 2010 09:03  |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
In some recent posts it has been oberrved that code compiled with gcc/minqw had non void functions without a return.
This problem is easy to have and produce strange errors.
It would be great if you could add "-Wreturn-type" parameter when using gcc/mingw compiler.
In the same way, the "-Wall" could be considered. Perhaps it is pedantic, but it make sense as many little warnings can produce weird errors.
Best regards
Iñaki
|
|
|
Re: Problem with gcc compilers and -Wall [message #28613 is a reply to message #28589] |
Wed, 08 September 2010 10:58   |
|
Hi Koldo!
I believe that -Wall is overkill. Unless you want to add all those missing parentheses around && within || (which is the most common warning I think) to make the output at least a little bit readable Also there is a lot of warnings in 3rd party code in plugin directory, which obscure the output (even without -Wall).
I think that it should be up to the user to set up how pedantic should the compiler be. It is just a matter of writing the options into the build method setting. At least for debug mode, it is more difficult for release mode, but possible too and seeing the warnings in debug mode should be enough anyway.
Best regards,
Honza
|
|
|
|
Re: Problem with gcc compilers and -Wall [message #28644 is a reply to message #28589] |
Thu, 09 September 2010 09:33   |
mr_ped
Messages: 826 Registered: November 2005 Location: Czech Republic - Praha
|
Experienced Contributor |
|
|
-Wall is the first thing I set up before creating new project.
It's never an overkill. (ok, I know 1 or 2 type of warnings which are really not helpful because I never made such error they warn against and use that deliberately, but 99% of -Wall are valid objections and code can be improved)
edit:
"I think that it should be up to the user to set up how pedantic should the compiler be."
Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb.
[Updated on: Thu, 09 September 2010 09:35] Report message to a moderator
|
|
|
|
|
Re: Problem with gcc compilers and -Wall [message #28650 is a reply to message #28644] |
Thu, 09 September 2010 10:22   |
|
mr_ped wrote on Thu, 09 September 2010 09:33 | Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb. 
|
You are right about this Ped. Maybe if the Core didn't put out so many useless warning I would use the option sometimes too. I guess we should fill in those missing brackets and parenthesis...
Honza
|
|
|
|
|
Re: Problem with gcc compilers and -Wall [message #28660 is a reply to message #28659] |
Thu, 09 September 2010 21:45   |
|
Well, then maybe -Wall -Wno-parentheses? BTW: I always thought that those extra parentheses are suggested to prevent trouble in case someone writes non-conforming compiler 
Also -Wno-reorder would be nice, but that would have to be set only for C++, for C files it prints out warning.
Looking at the warnings, I observed following:
There is a lot of unused-variable warnings and few unused-function. Those could be fixed easily and it might improve readability.
There are some warnings that sound pretty dangerous. Like uninitialized variables. Or even more terrifying "operation on ‘q’ may be undefined". It is not that bad in the end, it belongs to the code that is bit messy, but probably OK (as far as I can tell ):q = q > 0 ? d.name.ReverseFind(':', q) : q = d.name.ReverseFind(':');
There is also few really stupid warnings. Like "‘main’ is usually a function". I believe you don't have to be C++ wizard to know that 
Honza
|
|
|
|
Re: Problem with gcc compilers and -Wall [message #28669 is a reply to message #28662] |
Fri, 10 September 2010 12:45   |
|
Maybe we could (optionally) silence (-Wno-xxx) the most common errors in U++ code (that is anything that is in uppsrc nest) and let the user control the verbosity for his portion of code, defaulting to -Wall. But IMHO that is far too fine grained and I would rather prefer adding those parentheses etc. into the code...
Honza
|
|
|
Re: Problem with gcc compilers and -Wall [message #28732 is a reply to message #28669] |
Tue, 14 September 2010 11:04  |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
I agree too with -Wall.... It helps writing bugfree code many times.
I also had an error of function with missing return at end, giving weird errors and I could locate it just compiling with MSC which has the warning enabled.
I think that the -Wall with -Wno-parentheses would be the best choice... and I think it would not require too many "fixes" in Upp sources.
Max
|
|
|
Goto Forum:
Current Time: Sat Apr 26 18:12:32 CEST 2025
Total time taken to generate the page: 0.02017 seconds
|
|
|