I have an old project targeting DOS (yes, really) which I need to update and re-compile. The project is using the Open Watcom 1.9 C / C++ compilers and the JWasm assembler. Under no circumstances I can use other compilers or assemblers, because that project contains a lot of code specific to them.
What works:
I can compile and link the project as is without any issues with the existing code. I can change code and can re-compile and link the project.
My problem:
While updating and improving the code, I would like to use a part of C99 syntax / extended syntax. Notably, I would like to use designators in array initializers like that:
double foo[2] = {
[0] = 1.5,
[1] = 0.5
};
I have read somewhere (can't remember where) that only gcc supports that syntax, but the Open Watcom 1.9 manuals state the opposite. From c_readme.pdf
, chapter 6.5, page 46:
6.5 Differences from Open Watcom Version 1.3
Following is a list of changes made in Open Watcom C/C++ 1.4:
• Support for C99 designated initializers has been added to the C compiler, for example "struct {int a, b;} c = {.a=0, .b=1};". This is also supported for arrays, for example "int a[4] = {[0]=5, [3]=2};".
Please note that I really tried to provide an authoritative link to that document, but right now openwatcom.org is down (again), and I can't remember the exact location of the document on that website. However, the document is included in the installation archive of OpenWatcom 1.9, which you can still can download. For example, the Windows Version for C is here.
When I try to compile a source file which uses designators in array initializers as shown above, I am getting just a syntax error from the respective line. I have tried the POSIX compiler driver as well as the normal C compiler, but both produce the same syntax error. These are the command lines I used:
owcc.exe -c -v -mtune=686 -g3f -Wstop-after-errors=20 -fmessage-full-path -fno-short-enum -fptune=586 -mcmodel=h -O0 -finline-math -Wextra -std=c99 -b DOS -fo=obj\Release\foo.obj foo.cpp
wpp.exe -6 -bt=DOS -d3 -e20 -ef -ei -er -fpi87 -fp5 -mh -od -wx -zdf -zff -zgf -zt256 -zu -fo=obj\Release\foo.obj foo.cpp
So what do I have to do to be able to use designators in array initializers with OpenWatcom C/C++ 1.9?
You can compile code with Open Watcom Compiler fork (see also option -za99) -
Output -