Keil™, An ARM® Company

Technical Support

ARMCC: REFERENCING C FUNCTIONS FROM C++


Information in this article applies to:

  • RealView C Compiler All Versions

QUESTION

I'm calling a C function called my_func from a C++ module.  When I try to build the project, I get the following linker error:

Error: L6218E: Undefined symbol my_func().

In my C++ module, I declared the function as follows:

extern void my_func (void);

What is wrong? How do I call a C function from C++?

ANSWER

To call a C function from C++, use the following type conversion notation:

extern "C" void my_func (void);

This tells the linker that the my_func function requires a C-style linkage to the C++ module.

MORE INFORMATION

  • Refer to page 126 of the RealView Compilation Tools Compiler and Libraries Guide, Version 3.0 for µVision

Last Reviewed: Monday, July 10, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure