if (IsOpenWatcom && target->GetTargetType() != ttStaticLib)
linkfiles << _T("file ");
Lol, that's a hack if I ever saw one

Anyway, for anybody having the same problem and arriving here by way of google, here's the very simple and straight forward work-around for people wanting to use OW to build for 16-bit DOS:
Copy the
OpenWatcom (W32) Compiler target config to a new one, let's call it
OpenWatcom DOS16.
In
Settings>Compiler>Global compiler settings> [select
OpenWatcom DOS16 as
Selected compiler] >
Other Settings>Advanced options...>Commands>Command:Link object files to console executable:$linker option quiet form DOS $link_options $libdirs file $link_objects name $exe_output $libs $link_resobjectsand in
Others>Object separator, make sure it is a simple comma (","). (So, we're adding
form DOS to make sure wlink.exe builds a DOS .EXE, and
file in front of
$link_objects because that's how wlink.exe wants it)
Repeat similarily for the other types of
Command: commands (
Link object files to dynamic library, static... etc).
Then change the
Settings>Compiler>Global compiler settings>Toolchain executables to:
C compiler: wcl.exe
C++ compiler: wcl.exeYou will also need the following in
Settings>Compiler>Global compiler settings>Search directoriesCompiler:
c:\watcom\hLinker:
c:\watcom\lib386
c:\watcom\lib386\dos
c:\watcom\lib286
c:\watcom\lib286\dosResource compiler:
c:\watcom\hIn
Settings>Compiler>Global compiler settings>Build optionsNumber of parallel builds: 1(otherwise the linker will fail because it can only run one instance at a time)
Further, I'd use 8.3 compliant paths and file names for less frustration potential.
This is in the general case, you might of course need other files for the linker and include directories depending on your project.
So, the only problem with copying the
OpenWatcom (W32) Compiler target is that the magic behavior of the file directive is not carried over, for obvious reasons. In fact, this is not really a work around at all, because the magic behavior for (W32) is completely unnecessary; it could be handled by the regular target options.
I'm running Code::Blocks 13.12 in Windows XP, and "Open Watcom C x86 16-bit Optimizing Compiler
Version 2.0 beta Apr 27 2014 22:29:25", that is the v2 fork by Jiri Malak. I have not actually tried anything else than building a very basic multi source file DOS16 console app, and I suspect that dynamic libraries etc will actually need further tweaks in
Advanced options... to build. Of course the above only applies exactly like this if you have installed the OpenWatcom compiler into
c:\watcom, and selected to install the DOS compiler components when running the OpenWatcom installation program.