[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: [Chicken-users] Compiling Chicken with Watcom .. type errors
From: |
Sergey Khorev |
Subject: |
Re[2]: [Chicken-users] Compiling Chicken with Watcom .. type errors |
Date: |
Tue, 24 Jan 2006 10:27:14 +0300 |
BM> I moved my computer away from the internet, fired up ol win98 and tried
BM> your program. As expected, it compiled ok and printed garbage.
BM>
BM> Next I removed the cast from the function pointer
BM> proc3 p = (proc3)proc; // (proc3) cast hides error
BM>
BM>
BM>
BM> Now the problem is exposed:-
BM>
BM> cd C:\bins\wtest
BM> wmake -f C:\bins\wtest\v1.mk -h -e
BM> wcc386 var.c -i=C:\watcom\h;C:\watcom\h\nt -w4 -e25 -zq -od -d2 -6r
BM> -bt=nt -mf
BM> var.c(14): Warning! W102: Type mismatch (warning)
BM> var.c(14): Note! N2003: source conversion type is 'void (*)(int
BM> __p1,int __p2,int __p3,... )'
BM> var.c(14): Note! N2004: target conversion type is 'void (*)(int
BM> __p1,int __p2,int __p3)'
BM> wlink name v1 d all SYS nt op m op maxe=25 op q op symf @v1.lk1
BM> Execution complete
BM>
BM> The solution is the to have the function pointer typedef match the
BM> declaration of the pointed to function which has ellipses.
BM>
BM> typedef void (*proc3)(int a1, int a2, int a3, ...); //
BM> added 'dots' to match function
The problem is that Chicken uses the same pointer type to call two types of
functions (with fixed size and variable number of args).
So your typedef will not work to call function (int, int, int).
The feedback on my bugreport showed that Watcom `-ecc' switch is complete crap
because it changes calling conventions even for library functions
(even Borland C++ 3.1 for Windows 3 did it better!). So the only solution is to
attach __cdecl to each non-fastcall Chicken function
and typedef. I hope `sed' will help me ;)))