I created some plugin files in C++ for my Unity3d app. So far the app was just a simple protype, so I tested only on my desktop with libraries compiled as DLL for Windows. Today I recompiled those files as .so(Shared Object) for Android(both arm and x86) and got a warning message.
warning : calling convention '__stdcall' ignored for this target [-Wignored-attributes]
1. This means all functions are compiled as __cdecl?
2. Can't I specify the calling convention in .so library?
I replaced __stdcall with __cdecl, but it also occurs a warning message.
Shared library type: this library is not backwards -compatible, can be updated and updates can be uninstalled. Clients link against a specific version of the library. Static shared libraries simulate static linking while allowing for multiple clients to reuse the same instance of the library.
F. 6.1 C Calling Convention In the C calling convention subprogram parameters are pushed on the stack by the caller from right to left. The caller itself is in charge of cleaning up the stack after the call. In addition, the name of a routine with C calling convention is mangled by adding a leading underscore.
A calling convention is a scheme for how functions receive parameters from their caller and how they return a result. The calling conventions can differ in where parameters and return values are placed (in registers; on the call stack; a mix of both), the order they are placed.
The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes vararg functions __cdecl . Functions that use this calling convention require a function prototype. The __stdcall modifier is Microsoft-specific.
Both of these are non-standard historical Microsoft baggage for IA32 (they are in fact non-portable, standards compliant extensions to C and C++, implemented by Microsoft's compilers and by GCC for interoperability), for which the *NIX world has - and never had a need.
On just about all ARM systems you'll ever encounter (and all Android ones), the calling convention is dictated by the ARM Procedure Call Standard. Not surprisingly, there is no equivalent for ARM as there is no need for them.
Your best course of action is to use empty macros to make them go away.
#define __cdecl
#define __stdcall
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With