Geoff Chappell - Software Analyst
This option directs LINK to treat warnings as errors.
No arguments are permitted. The switch is /wx only.
The /wx option is for the command line only. It is not valid as a directive in an object file.
The general effect of this option is to arrange that occurrence of a warning is itself an error (LNK1218). Should a warning occur, the corresponding warning message is followed by the error message and by termination. The warning number becomes the exit code.
The /wx option is irrelevant for warnings that have been successfully registered to be ignored (as done with the /ignore option). If such a warning occurs while /wx is active, then there is no warning message, no error message and no termination.
Warning LNK4224 is a hard-coded exception. It warns against using an option that has become obsolete. The intention seems to be that this warning is important enough that it must be seen and /ignore therefore does not disable it. Yet it is not so severe that /wx should make an error of it. If warning LNK4224 occurs while /wx is active, then there is a warning message, but no error message and no termination.
One more exception is made for warning LNK4219. This presently occurs only for certain machine types (namely the SH3 and PPC families and the IA64). It tells of a fixup overflow that is resolved by inserting a thunk. In each case where the warning condition is detected, it is anyway considered so unimportant that the corresponding warning message is only bothered with if /verbose is active. If /wx is also active, then rather than letting so slight a problem turn into an error, the warning is simply skipped.
For who knows what reason, this obviously convenient switch is apparently undocumented. A corresponding switch for the compiler, also /WX (necessarily in upper case), has long been documented. Microsoft even recommends that “for a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects.” Surely this argument would retain at least some merit when applied to linking?
Though the /wx switch may be undocumented, Microsoft does use it in the master makefile for the Windows DDK. Indeed, the switch is active by default, being skipped only if the user knows to define the macro BUILD_ALLOW_LINKER_WARNINGS (which the DDK documentation does not list among the Build Utility Macros).