Recent

Author Topic: How to check if a given static library use STDCALL or CDECL?  (Read 472 times)

guest65405

  • Guest
How to check if a given static library use STDCALL or CDECL?
« on: March 29, 2020, 05:24:57 am »
I was given a static library compiled by MinGW64, whose has an extension .a but not the regular .lib I'm familiar with. No further information was provided other than the API document. How could I check if it use STDCALL or CDECL calling convention?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8222
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to check if a given static library use STDCALL or CDECL?
« Reply #1 on: March 29, 2020, 05:40:11 am »
I was given a static library compiled by MinGW64, whose has an extension .a but not the regular .lib I'm familiar with. No further information was provided other than the API document. How could I check if it use STDCALL or CDECL calling convention?
Use objdump -t <that .a>. If the symbols have @<some integer> suffix, it's stdcall. Otherwise, assume cdecl (if there's no other possibilities).
Reference: https://en.wikipedia.org/wiki/Name_mangling

guest65405

  • Guest
Re: How to check if a given static library use STDCALL or CDECL?
« Reply #2 on: March 29, 2020, 06:50:38 am »
I was given a static library compiled by MinGW64, whose has an extension .a but not the regular .lib I'm familiar with. No further information was provided other than the API document. How could I check if it use STDCALL or CDECL calling convention?
Use objdump -t <that .a>. If the symbols have @<some integer> suffix, it's stdcall. Otherwise, assume cdecl (if there's no other possibilities).
Reference: https://en.wikipedia.org/wiki/Name_mangling
As I didn't see any @ I think it should be CDECL. Thanks.

PascalDragon

  • Hero Member
  • *****
  • Posts: 1698
  • Compiler Developer
Re: How to check if a given static library use STDCALL or CDECL?
« Reply #3 on: March 29, 2020, 01:03:40 pm »
I was given a static library compiled by MinGW64, whose has an extension .a but not the regular .lib I'm familiar with. No further information was provided other than the API document. How could I check if it use STDCALL or CDECL calling convention?

If it's a 64-bit library then it doesn't matter as on x86_64 there is no difference between calling conventions (they only differ by platform, namely Win64 vs. everyone else).

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8465
  • FPC developer.
Re: How to check if a given static library use STDCALL or CDECL?
« Reply #4 on: March 29, 2020, 04:39:25 pm »
If it's a 64-bit library then it doesn't matter as on x86_64 there is no difference between calling conventions (they only differ by platform, namely Win64 vs. everyone else).

Well, vectorcall is different.

PascalDragon

  • Hero Member
  • *****
  • Posts: 1698
  • Compiler Developer
Re: How to check if a given static library use STDCALL or CDECL?
« Reply #5 on: March 30, 2020, 09:38:51 am »
If it's a 64-bit library then it doesn't matter as on x86_64 there is no difference between calling conventions (they only differ by platform, namely Win64 vs. everyone else).

Well, vectorcall is different.

Okay, yes, point taken, but those are rather rare.  :-[

 

TinyPortal © 2005-2018