Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Convention with a shared library for android

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.

like image 518
Jenix Avatar asked Sep 22 '15 14:09

Jenix


People also ask

What does Android shared library do?

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.

What is AC calling convention?

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.

What is Winapi calling convention?

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.

What is __ Stdcall?

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.


1 Answers

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
like image 145
marko Avatar answered Nov 12 '22 22:11

marko