Keil Logo

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

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, November 9, 2018


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.