Jump to content
Fraser

cdecl

Recommended Posts

I am not sure what is happening when I export functions with __cdecl.  When I build with 32-bit clang there is one prefixed underscore on all function names.  When I build with 64-bit clang there is no prefixed underscore on function names.  The documentation says this about cdecl: "Note: This feature is available only for the classic bcc32 compiler, not for the modern Clang-enhanced compiler."  It also says:"Note: The __cdecl form is the only one supported by C++Builder 64-bit Windows (BCC64)."  Is this not a contradiction?

 

The compiler option "Generate underscores on symbol names" made no difference to my 32-bit builds.  I have not found any way of using cdecl with 32-bit builds and to not get leading underscores which means I cannot build zlib1.dll which specifies no underscores.

Share this post


Link to post
3 hours ago, Fraser said:

When I build with 32-bit clang there is one prefixed underscore on all function names.

That is normal behavior.

Quote

When I build with 64-bit clang there is no prefixed underscore on function names.

That is also normal behavior.

Quote

The documentation says this about cdecl: "Note: This feature is available only for the classic bcc32 compiler, not for the modern Clang-enhanced compiler."  It also says:"Note: The __cdecl form is the only one supported by C++Builder 64-bit Windows (BCC64)."  Is this not a contradiction?

Calling conventions like cdecl and stdcall simply don't exist in 64bit, and they are ignored completely when used in code.  There is only 1 standardized 64bit calling convention, and its behaviors are dictated by the 64bit ABI.  And the 64bit calling convention indeed does not use the same name mangling rules that the 32bit cdecl calling convention uses.

Quote

I have not found any way of using cdecl with 32-bit builds and to not get leading underscores

Use a .DEF file to control how the linker (or IMPLIB tool) formats exported names, and what internal names those exported names map to.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×