#122306 - PypeBros - Sun Mar 18, 2007 4:50 pm
there's one thing that has been annoying me for ages with DevKitPro: whenever gcc/g++ outputs an error message, it always uses the whole full path rather than the filename, e.g.
Quote: |
/tux/install/DS/apple-rumble-src/rumble/arm9/source/appleblock.cpp:56: warning:
enumeration value 'BST_POP' not handled in switch
/tux/install/DS/apple-rumble-src/rumble/arm9/source/appleblock.cpp:56: warning:
enumeration value 'BST_POP2' not handled in switch
|
etc.
while just "appleblock.cpp: 56: warning : ...." would have been just enough.
Does anyone have a patch around that ?
_________________
SEDS: Sprite Edition on DS :: modplayer
#122657 - poslundc - Wed Mar 21, 2007 12:48 am
The file name displayed ought to be the file name that was passed in on the command line to GCC.
So if you have your makefile CD into the source directory root before processing files (or if your makefile is located in that source directory), you can pass in relative file paths instead of absolute ones, and that's what you'll get.
That said, however, it's widely considered good practice to treat compiler warnings as errors, and to fix them whenever you find them. Otherwise as your project grows it becomes a jungle of ignored warnings and they lose all meaning, so that when a warning that could indicate an actual error to you appears you wind up not noticing it, and the warnings serve no purpose. If someone on my team checks in work that generates a warning it's considered broken code.
Dan.
#122664 - tepples - Wed Mar 21, 2007 2:47 am
poslundc wrote: |
That said, however, it's widely considered good practice to treat compiler warnings as errors, and to fix them whenever you find them. Otherwise as your project grows it becomes a jungle of ignored warnings and they lose all meaning, so that when a warning that could indicate an actual error to you appears you wind up not noticing it, and the warnings serve no purpose. If someone on my team checks in work that generates a warning it's considered broken code. |
I assume that you mean that your projects use -Wall -Wextra -pedantic -Werror. In such an environment, how does the programmer suppress warnings about (currently) unused arguments, (currently) unused static functions, and the like? Does your team accept GCC-specific attributes such as __attribute__((unused)), or does it insist that all code must compile additionally on compilers that do not understand GNU extensions?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122667 - Miked0801 - Wed Mar 21, 2007 4:00 am
__attribute__((unused)) is used quite a bit on my team to surpress unused param warnings. Unused statics can usually be commented out quite easily. What other warnings do you consider not worth fixing immediately? BTW, I'm of one mind with Poslund on this one. Warnings are errors.
#122671 - sgeos - Wed Mar 21, 2007 4:53 am
Miked0801 wrote: |
__attribute__((unused)) is used quite a bit on my team to surpress unused param warnings. Unused statics can usually be commented out quite easily. |
What a fantasic way of letting people know that you know what you are doing.
Code: |
#define UNUSED __attribute__((unused))
int toBeCallByPointer_NullFunction(UNUSED int pX, UNUSED char *pC)
{
return 0;
} |
Quote: |
BTW, I'm of one mind with Poslund on this one. Warnings are errors. |
I agree. Warnings generally mean I did something stupid and my code won't work. They need to be fixed.
-Brendan
#122686 - HyperHacker - Wed Mar 21, 2007 5:52 am
Usually, yes, but sometimes you get warnings about silly things like no newline at end of file, converting 0xFF to signed, etc. And in some cases you're being warned about doing something you don't usually do (integer math with pointers, comparing/converting between variables of different sizes, etc) but in this case intended to do.
_________________
I'm a PSP hacker now, but I still <3 DS.
#122700 - keldon - Wed Mar 21, 2007 10:39 am
Warnings are warnings for good reasons.
#122715 - tepples - Wed Mar 21, 2007 1:39 pm
HyperHacker wrote: |
And in some cases you're being warned about doing something you don't usually do (integer math with pointers, comparing/converting between variables of different sizes, etc) but in this case intended to do. |
In these cases, casts show your intention to other people reading your code.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122719 - sgeos - Wed Mar 21, 2007 2:53 pm
tepples wrote: |
HyperHacker wrote: | And in some cases you're being warned about doing something you don't usually do (integer math with pointers, comparing/converting between variables of different sizes, etc) but in this case intended to do. |
In these cases, casts show your intention to other people reading your code. |
In this case "people" includes the compiler.
-Brendan
#122744 - gmiller - Wed Mar 21, 2007 5:22 pm
By explicitly telling the compiler what you want it to do allows the compiler to make better decisions. So implicit casting is bad and explicit is good.
#122746 - poslundc - Wed Mar 21, 2007 5:56 pm
tepples wrote: |
I assume that you mean that your projects use -Wall -Wextra -pedantic -Werror. |
We aren't using GCC, but yes, pretty much the equivalent of that. We don't force warnings to be treated as errors by the compiler, mainly because it's too easy for a programmer to write code that generates a warning in release builds (which a non-technical producer might be making) but not in the debug builds that the programmer is creating. So while I would ideally like those warnings to throw as errors, it's not worth bottlenecking the production process.
Quote: |
In such an environment, how does the programmer suppress warnings about (currently) unused arguments, (currently) unused static functions, and the like? Does your team accept GCC-specific attributes such as __attribute__((unused)), or does it insist that all code must compile additionally on compilers that do not understand GNU extensions? |
We use compiler-specific notation to indicate unused parameters, which I'm not too happy about. We are also trying to encourage programmers not to apply that band-aid blindly, but to instead evaluate whether the compiler "has a point" and the extraneous parameter should be refactored out.
Dan.
#122751 - tepples - Wed Mar 21, 2007 7:35 pm
poslundc wrote: |
We use compiler-specific notation to indicate unused parameters, which I'm not too happy about. We are also trying to encourage programmers not to apply that band-aid blindly, but to instead evaluate whether the compiler "has a point" and the extraneous parameter should be refactored out. |
I understand that unused parameters should be refactored out of a stand-alone program eventually, but sometimes it's hard to change interfaces that other developers use. In a library or in functions that a library calls back, the parameter still has to be there because taking it out would break existing code. For example, there are quite a few HWNDs passed to the WinAPI that Windows has ignored in all versions after 3.1.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#122766 - HyperHacker - Wed Mar 21, 2007 10:59 pm
Alright, I found the specific case I was thinking of when I wrote that post. I have an array of function pointers (32-bit) in a Windoze app, and want to compare the return from StackWalk64() to these pointers. The function gives a 64-bit pointer and I need to iterate through my array, checking if element[x] < pointer < element[x+1]. Since the pointer is 64 bits, but the elements are 32, even if I cast the elements to DWORD64 during the compare it generates a warning "cast from pointer to integer of different size". But since my program is being compiled for Win32, these elements' values will never exceed the 32-bit range, so I don't want to make them 64-bit which would take up twice as much memory for no good reason.
_________________
I'm a PSP hacker now, but I still <3 DS.
#122769 - tepples - Wed Mar 21, 2007 11:29 pm
Isn't there a StackWalk32()?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.