Calling conventions: Different resolving of CALLBACK

Started by peterfarge, August 07, 2009, 12:33:27 PM

Previous topic - Next topic

peterfarge

Hello Forum,

I have created a Progressbar within a CodeBlocks project. Now I want to move my prj to Pelles Compiler. The problem is that the third param of CreateTimerQueueTimer() is marked by PellesCC. The message is:
QuoteC:\Eigene Dateien\abcd\PellesCrk\main.c(54): warning #2168: Operands of '=' have incompatible types 'void __fastcall function(void *, unsigned char)' and 'void __stdcall function(void *, unsigned char)'.
If I do a double click on it, it shows me the following function:HANDLE hTimerMain=NULL;
void WINAPI alarmInterrupt(PVOID lpParameter, unsigned char TimerOrWaitFired) {
    if(!printProgress()) {
        DeleteTimerQueueTimer(NULL, hTimerMain, NULL);

        CreateTimerQueueTimer(
            &hTimerMain,
            NULL,
            alarmInterrupt,    /*############ <- This is the error line. */
            NULL,
            1000*PRINTERVAL,
            0,
            0
        );
    }
}


Winapi is __stdcall. But why is the third param of CreateTimerQueueTimer() __fastcall? If you look at this page (Link) you will see that it is a function ptr of WAITORTIMERCALLBACK and this uses CALLBACK. CALLBACK is defined in windef.h. If I look at Pelles\Include\Win\windef.h CALLBACK and Winapi.h are booth __stdcall. So where this __fastcall comes from? (My prj includes windows.h, which includes windef.h)


Thanks

Peter

Stefan Pendl

Quote from: peterfarge on August 07, 2009, 12:33:27 PM
HANDLE hTimerMain=NULL;
void WINAPI alarmInterrupt(PVOID lpParameter, unsigned char TimerOrWaitFired) {
    ...
}


Winapi is __stdcall. But why is the third param of CreateTimerQueueTimer() __fastcall? If you look at this page (Link) you will see that it is a function ptr of WAITORTIMERCALLBACK and this uses CALLBACK. CALLBACK is defined in windef.h. If I look at Pelles\Include\Win\windef.h CALLBACK and Winapi.h are booth __stdcall. So where this __fastcall comes from? (My prj includes windows.h, which includes windef.h)
If the function is a callback you should use CALLBACK instead of WINAPI, if I am not mistaken.

__fastcall is the default for WINAPI, when compiling for 64-bit Windows.
---
Stefan

Proud member of the UltraDefrag Development Team