| |||
| Home > Mixing C, C++, and Assembly Language > Rules for calling C++ functions from C and assembly language | |||
The following rules apply to calling C++ functions from C and assembly language:
To call a global
C++ function, declare it extern "C" to give it
C linkage.
Member functions, both static and non static, always
have mangled names. Using the __cpp keyword of
the embedded assembler means that you do not have to find the mangled names
manually.
C++ inline functions cannot be called from C unless you ensure that the C++ compiler generates an out-of-line copy of the function. For example, taking the address of the function results in an out-of-line copy.
Nonstatic member functions receive the implicit this parameter
as a first argument in R0, or as a second argument
in R1 if the function returns a non int-like
structure. Static member functions do not receive an implicit this parameter.