Re: Need help GTK on Windows

new topic     » goto parent     » topic index » view thread      » older message » newer message
SDPringle said...

It is supposed to ignore the + on Linux.

And it very well does. So I don't see how any of that is at all necessary. On Linux there is only one calling convention: CDECL.

  • If you include "+" on Windows, you're forcing the calling convention from STDCALL to CDECL.

  • If you include "+" on Linux, you're forcing the calling convention from CDECL to CDECL.

Either way, the "+" gets stripped from the function name before being looked up via GetProcAddress or dlsym.

Here are the relevant code snippits from be_machine.c in the DefineC function.

... 
 
#ifdef EWINDOWS 
    /* On Windows we normally expect routines to restore the stack when they return. */ 
    convention = C_STDCALL; 
#else 
    /* On Unix like Operating Systems the caller must always restore the stack */ 
    convention = C_CDECL; 
#endif 
 
... 
 
    /* C .dll routine */ 
    if (IS_ATOM(routine_name)) 
        RTFatal("routine name must be a sequence"); 
    routine_ptr = SEQ_PTR(routine_name); 
    Ref(routine_name); 
    if (routine_ptr->length >= TEMP_SIZE) 
        RTFatal("routine name is too long"); 
    routine_string = TempBuff; 
    MakeCString(routine_string, routine_name, TEMP_SIZE); 
    if (routine_string[0] == '+') { 
        routine_string++; 
        convention = C_CDECL; 
    } 
#ifdef EWINDOWS 
    proc_address = (intptr_t (*)())GetProcAddress((void *)lib, routine_string); 
    if (proc_address == NULL) 
        return ATOM_M1; 
#else 
    proc_address = (intptr_t (*)())dlsym((void *)lib, routine_string); 
    if (dlerror() != NULL) 
        return ATOM_M1; 
#endif 
 
... 
 
    c_routine[c_routine_next].address = proc_address; 
    c_routine[c_routine_next].name = routine_ptr; 
    c_routine[c_routine_next].arg_size = SEQ_PTR(arg_size); 
    c_routine[c_routine_next].return_size = t; 
    c_routine[c_routine_next].convention = convention; 
 
... 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu