How DMD's -w *Prevents* Me From Seeing My Warnings

Walter Bright newshound1 at digitalmars.com
Fri Feb 12 14:30:50 PST 2010


Nick Sabalausky wrote:
> Ok, that is a big improvement (thanks!!!), but this still remains:
> 
> 1. I compile my program, with warnings as I always do (because I want to be 
> told about them, and as early as possible).
> 2. I fix all my errors, but I get a warning in an external library.
> 3. Now I have to go modify my build script and recompile just to get the 
> output files that DMD arbitrarily refused to give me before (and then go 
> edit my built script again to turn them back on). Which is not impossible, 
> but it's all for...what benefit exactly? I mean, even if there were a 
> legitimate reason for forcing any warnings to suppress output files (and I 
> very much dispute that there is), the fact I can get the same damn output 
> files anyway by shutting the warnings off and recompiling renders the whole 
> "feature" pointless. You may as well just write the output files anyway and 
> save people the bother of working around it.

Here's how I set up a makefile to build with different options:

----------------------------
FLAGS=

foo : foo.d
     dmd foo $(FLAGS)

warnings :
     make FLAGS=-w
----------------------------

Use
	make

to do a regular build, and

	make warnings

to do a warnings build. You don't have to edit things. Having make 
recursively call itself setting various options on and off is a compact 
and easy way to do it. I use this all the time for various kinds of builds.

So, for your case, I'd "make warnings", fix all the warnings that I 
intend to, then just do "make" for the executable build.

As for why warnings don't just slide through without creating any 
errors, I'll give my usual rant on them:

If they go ahead and produce the output files anyway, you never see 
them! They scroll up and off your window, you don't notice them. Your 
automated build system never notices them, and happily reports that 
everything went swimmingly.

Your difficulty with the 3rd party library warnings is a classic example 
of why I spent a lot of energy resisting having warnings in the language 
in the first place.



More information about the Digitalmars-d mailing list