chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Compiling Chicken with Watcom


From: Sergey Khorev
Subject: [Chicken-users] Compiling Chicken with Watcom
Date: Mon, 23 Jan 2006 13:34:58 +0300

Finally I've figured out the main showstopper to get Chicken compiled by Watcom 
(at least at the moment). To be precise, chicken.exe and chicken-static.exe can 
be compiled but they don't work :)

The problem is in the default Watcom calling convention (it's similar to MSVC's 
__fastcall): it uses registers to pass few first arguments. This doesn't work 
for functions with a variable number of arguments.
E.g., the following program will not work properly without the -ecc switch (== 
use __cdecl calling convention)
-----
#include <stdio.h>

typedef void (*proc3)(int a1, int a2, int a3);

void proc(int a1, int a2, int a3, ...)
{
        printf("%d %d %d\n", a1, a2, a3);
}

int main()
{
        proc3 p = (proc3)proc;
        p(1, 2, 3);
        return 1;
}
-----
But, the -ecc switch causes internal compiler error.
I've created a bug report (http://bugzilla.openwatcom.org/show_bug.cgi?id=505) 
for it. Workaround "#pragma inline-depth(0);" doesn't help.

If I correctly undertsand, Chicken-generated C can cast to C_procXX both 
"normal" and vararg functions. Should we wait for feedback or does anyone know 
any workarounds?

Felix, can we add __cdecl for each C_procXX typedef and every function, which 
can be called by casting to C_procXX? Theoretically speaking, this might help 
to avoid internal compiler error because not all functions will be __cdecl'ed, 
but I hardly believe in that.

PS Please keep both my emails in cc field, it's intended.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]