3.7 Rules for calling C++ functions from C and assembly language

Some rules apply when 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.

Non-ConfidentialPDF file icon PDF versionARM DUI0471M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.