Archicad C++ API
About Archicad add-on development using the C++ API.

[api wish] Win specific API wish ( __fastcall )

Oleg
Expert
Small wish for Graphisoft.
As far as I understand GS uses __fastcall calling convention by default for exported functions from DLL some (or all) modules.
Though this strange decision, but if so, it would be good if the calling convention was specified for all functions at their declaration ( like GeometryModule ). Some functions dont have it.
For example, if I use DG::Alert in a project I should set __fastcall for entirely project that to link it. It is not always desirable.
3 REPLIES 3
Andras Babos
Graphisoft Alumni
Graphisoft Alumni
Hi Oleg,

You're right, GS uses __fastcall by default. So if you don't see a calling convention declaration for a function, it means it uses fastcall.
By quickly browsing through the API headers I couldn't find any functions which don't have a calling convention set. The one you mention (DG::Alert) is specified as:
 
short  (CCALL *dgAlert) (short alertType, const char* titleText, const char* largeText, const char* smallText, const char* button1Text, const char* button2Text, const char* button3Text); 

in the DGFunctionTable struct (DGLib/DG.h), and CCALL in turn is defined in GSRoot/Definitions.hpp as:
 
#ifndef	CCALL 
  #if defined (macintosh) 
    #define CCALL 
  #else 
    #define CCALL __cdecl 
  #endif 
#endif 


Could you point out those functions which don't have a calling convention set?
Oleg
Expert
Andras wrote:
Hi Oleg,

Could you point out those functions which don't have a calling convention set?
You mean DGAlert macros, but I meant the Alert function in DG namespace ( DG::Alert, It is in DGModule.hpp ).
DGModule.hpp contains number of functions starting from InitModule and up to the end of the file which are declared without calling convention.
In spite of what they are in namespace they are just functions as against of class members ( which use thiscall by default ).
Andras Babos
Graphisoft Alumni
Graphisoft Alumni
You're right of course... It was my mistake.
Setting calling conventions right is now on the list for the API of the next ArchiCAD version.