how could I define empty macro from commandline?
For MSVC I can use:
> cl -D_U_="" test.c
it is equal to
#define _U_
It unfortunately does not work with OWC
if I use
> cl -D_U_="" test.c
it is equal to
#define _U_ ""
Using -D_U_='' looks more promissing with OWC.
It works well if I invoke preprocessing only following compilation in
the 2nd step
> cl -P -D_U_='' test.c
> cl test.i
Unfortunately it does not work if I try to invoke it simply with one pass
> cl -D_U_='' test.c
It cause or syntax error or wcc386 crash, depending where _U_ is used in
source code.
Thanks for any hint.
Tomas
Most likely your shell (CMD.EXE?) is eating the double quotes. Try
escaping them (I think the ^ character should do it).
try to use
cl -D_U_=\"\" test.c
I do not use "cl", but for "wcc386" I would use either of the following in
order to define a macro with a null (empty) value:
wcc386 /d_U_ test.c
wcc386 /d_U_= test.c
-- from CyberSimian in the UK
Example program, which I need to compile is following:
void main(int i _U_) {
}
Various results are:
1) -D_U_="" (_U_ is expanded to "")
>cl -D_U_="" -showwopts -nologo test.c
test.c
wcc386 -d_U_="" -bt=nt -zlf -ei -zq -oe=0 -4r -ofr -j -w1 -aa test.c
test.c(3): Error! E1009: Expecting ',' but found ''
2) -D_U_= or -D_U_ (_U_ is expanded to 1)
>cl -D_U_= -showwopts -nologo test.c
test.c
wcc386 -d_U_ -bt=nt -zlf -ei -zq -oe=0 -4r -ofr -j -w1 -aa test.c
test.c(3): Error! E1009: Expecting ',' but found '1'
3) -D_U_='' (_U_ is expanded with preprocessor probably to some empty
token which is not hadnled well later in compiler)
>cl -D_U_='' -showwopts -nologo test.c
test.c
wcc386 -d_U_='' -bt=nt -zlf -ei -zq -oe=0 -4r -ofr -j -w1 -aa test.c
test.c(3): Error! E1009: Expecting ',' but found ''
3a) -D_U_='' with two passes (preprocess, compilation)
>cl -P -D_U_='' -showwopts -nologo test.c
test.c
wcc386 -d_U_='' -bt=nt -zlf -ei -zq -pl -od -j -w1 -fo=test.i -aa test.c
>cl -showwopts -nologo test.i
test.i
It works, but it is not usable to preprocess and compile it in two steps.
The macro _U_ can not be removed from source manually as
the source is used with more compilers on more platforms and macro _U_
has special mening for GCC.
I am trying to compile the Wireshark (www.wireshark.org) for Win32 with
Open Watcom.
BTW following example
void main(int i) {
_U_;
}
causes following crash (using 1.8RC3)
>cl -D_U_='' -showwopts -nologo test.c
test.c
wcc386 -d_U_='' -bt=nt -zlf -ei -zq -oe=0 -4r -ofr -j -w1 -aa test.c
The instruction at 0x6945325f referenced memory at 0x7220666f.
The memory could not be read.
Exception fielded by 0x00403520
EAX=0x00000000 EBX=0x0012f8cc ECX=0x6944be00 EDX=0x7220666f
ESI=0x6944be00 EDI=0x7220666f EBP=0x0012f8cc ESP=0x0012f6c8
EIP=0x6945325f EFL=0x00010246 CS =0x0000001b SS =0x00000023
DS =0x00000023 ES =0x00000023 FS =0x0000003b GS =0x00000000
Stack dump (SS:ESP)
0x00000000 0x00000000 0x00000000 0x00000000 0x545c3a44 0x73616d6f
0x6f72705c 0x65745c6a 0x00317473 0x00000000 0x00000000 0x00000000
0x00000000 0x00740073 0x00005ccf 0x0012f490 0x00140000 0x0012ffac
0x0012f75c 0x00c80000 0xffffffff 0x7c91428f 0x00000000 0x00000000
0x69452f40 0x69402a31 0x00000000 0x69452f40 0x0012f775 0x00000000
0x00000000 0x69449c17 0x69402a00 0x009ef81c 0x0012f79d 0x0000012c
0x6944beb6 0x0012f79d 0x0000012c 0x00000000 0x00000005 0x0012f78c
0x6940b4fb 0x0012f79d 0x00000080 0xffffffff 0x00000000 0x00000000
0x6940b6e8 0x00000000 0x69410691 0x00000000 0x00000007 0x00000002
0x6941bd04 0x00000002 0x69453ffc 0x00000008 0x009ef7e0 0x009ef7dc
0x694b3bd8 0x694107d8 0x008f0444 0x00000000 0x69407e44 0x009ea6fc
0x008f00bc 0x009ef7f8 0x009ef7f4 0x694b3bd8 0x694107d8 0x00000016
Fatal error: Unable to execute 'wcc386'
One suggestion was to use /D instead of -D, on which you did not report.
I'd also try this:
-D_U_=/*dummy*/
which might just work...
--
HTH, Steve
there is no diiference between /D and -d
>
> I'd also try this:
>
> -D_U_=/*dummy*/
>
> which might just work...
none of following variants works either
-D_U_=/*a*/
-D_U_=\/*a*\/
-D_U_="/*a*/"
-D_U_='/*a*/'
I hope it will not make me giving up using Open Watcom after 2 days of
using it. :-)
> Example program, which I need to compile is following:
>
> void main(int i _U_) {
> }
As a workaround to defining the macro on the command line you can create
a file _u_.h containing only the line
#define _U_
and compile with
wcc386 test.c -fi=_u_.h
Marc
Thanks, it is a good idea!
Next issues which I am not able to solve on my own will surely come as
it is not funny to compile project with 80MB of C source in 1500 files.