NO

Author Topic: Calling conventions: Different resolving of CALLBACK  (Read 2621 times)

peterfarge

  • Guest
Calling conventions: Different resolving of CALLBACK
« on: August 07, 2009, 12:33:27 PM »
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:
Quote
C:\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:
Code: [Select]
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

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Calling conventions: Different resolving of CALLBACK
« Reply #1 on: August 07, 2009, 12:54:32 PM »
Code: [Select]
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

peterfarge

  • Guest
Re: Calling conventions: Different resolving of CALLBACK
« Reply #2 on: August 07, 2009, 05:24:08 PM »
Oh, thats new. Thanks :)