I have always been fond of getting warnings for unused variables, since I sometimes forget to remove them manually when I change the code.
By default, Dev-C++ does not turn these warnings on, but I think that there should be an explicit option to turn this on. Adding -Wunused-variable to the compiler options from within Dev works like a charm, but I think that for newbies it should be turned on by default.
One could argue that unused variables pose no risk, and that is probably correct, but...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-20
Use the following compiler option:
-Wall
I would also recommend -Werror, and -Wformat. (because '-Wall' does not quite mean 'all').
Check the warning options here:http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Warning-Options.html#Warning%20Options
If you add these options to the compiler options under Tools|Compiler options., thet will applied to all subsequently created projects (like a default). For existing projects you will have to add them manually to the project options.
Clifford.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It doesn't according to the documentation given from that link. Read the section that starts with "The following -W... options are not implied by -Wall"
qWake
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But -Wformat seems to be implied with -Wall, despite what Clifford said.
-Werror is not implied by -Wall, however. I don't think I want that one, though. I will always clean off all warnings at the end anyway, so converting them to errors makes no sense to me.
The original question still remains, though:
Why doesn't Dev-C++ have any of these options as the default? There is a checkbox to inhibit warnings, but no chekbox to add them. By default Dev-C++ doesn't give many warnings.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-12-20
In a large project (I typically deal with several hundred sourcefiles), especially when working in a team, it is easy not to spot warnings amongst the compiler output. That is why I use -Werror. Also often warnings are indicitive of actual errors, so you may as well stop and fix them anyway. It also improves your coding style, after a while you write code that is just correct in the first place.
Clifford.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is one of those topics that can get religous and bellicose in short order.
It is interesting that it is also one of those areas where two people can look at the same data and come to opposite conclusions. The demographics (*I* think) for Dev-C++ skew towards the very new programmer. Evidence suggests many of them do not even understand the difference between a warning and an error, and many used to freak when a warning was generated about deprecated headers, so, you could say
(1) Making them fix warnings is a good thing, gets them started right
(2) Warnings scare off new folks who otherwise, once they get their feet on the ground, would program just fine
Both have some merit...
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have always been fond of getting warnings for unused variables, since I sometimes forget to remove them manually when I change the code.
By default, Dev-C++ does not turn these warnings on, but I think that there should be an explicit option to turn this on. Adding -Wunused-variable to the compiler options from within Dev works like a charm, but I think that for newbies it should be turned on by default.
One could argue that unused variables pose no risk, and that is probably correct, but...
Use the following compiler option:
-Wall
I would also recommend -Werror, and -Wformat. (because '-Wall' does not quite mean 'all').
Check the warning options here:http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Warning-Options.html#Warning%20Options
If you add these options to the compiler options under Tools|Compiler options., thet will applied to all subsequently created projects (like a default). For existing projects you will have to add them manually to the project options.
Clifford.
"because '-Wall' does not quite mean 'all'"
Actually it does =)
Kip
It doesn't according to the documentation given from that link. Read the section that starts with "The following -W... options are not implied by -Wall"
qWake
But -Wformat seems to be implied with -Wall, despite what Clifford said.
-Werror is not implied by -Wall, however. I don't think I want that one, though. I will always clean off all warnings at the end anyway, so converting them to errors makes no sense to me.
The original question still remains, though:
Why doesn't Dev-C++ have any of these options as the default? There is a checkbox to inhibit warnings, but no chekbox to add them. By default Dev-C++ doesn't give many warnings.
In a large project (I typically deal with several hundred sourcefiles), especially when working in a team, it is easy not to spot warnings amongst the compiler output. That is why I use -Werror. Also often warnings are indicitive of actual errors, so you may as well stop and fix them anyway. It also improves your coding style, after a while you write code that is just correct in the first place.
Clifford.
This is one of those topics that can get religous and bellicose in short order.
It is interesting that it is also one of those areas where two people can look at the same data and come to opposite conclusions. The demographics (*I* think) for Dev-C++ skew towards the very new programmer. Evidence suggests many of them do not even understand the difference between a warning and an error, and many used to freak when a warning was generated about deprecated headers, so, you could say
(1) Making them fix warnings is a good thing, gets them started right
(2) Warnings scare off new folks who otherwise, once they get their feet on the ground, would program just fine
Both have some merit...
Wayne
Further to what Wayne says above, when I learnt C (and also when learning C++) I found:
-wall -ansi -pedantic
To be very useful in terms of making me *really* think about my code. (My aim being to learn something I could use with any compiler[1])
Iain
[1] At that point I'd not considered that not all compilers would adhere to the standards.
Wayne, you are really cool when you speak in earnest, like here, instead of apple juiced.
Kip
I hate apple jiuce!
Wayne