Need stdcall for import function?

I'm interested:

When I import a function from a dynamic link library that is exported using the stdcall calling convention , is it necessary to add stdcall to external in Delphi since version 7?

i.e.

LIBNAME int __stdcall Foo(void); 

a

 function Foo: Integer; stdcall; external 'libname.dll'; 

or i can just leave

 function Foo: Integer; external 'libname.dll'; 

IIRC will use stdcall by default, but I'm not 100% sure about this, your opinion is required.

EDIT

The question is related to the 32-bit library, Arno Bushes made a good point of view that for 64-bit, the calling convention is not taken into account, since there is only one.

+4
source share
1 answer

If you omit stdcall then the default calling convention register will be used. Therefore, you must indicate that stdcall .

The fact that you are using external does not change anything. The standard register calling convention, even for external imports.

Of course, this only matters when compiling for 32 bits. On x64 Windows, there is a single calling convention specified in the ABI . On Windows x64, all calls specified in the code are ignored, and all function calls are made using the Windows x64 calling convention.

+10
source

Source: https://habr.com/ru/post/1402601/


All Articles