We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am trying to call a C function from the interrupt subroutine in LPC3250.
When I call the function from a C file, there is no problem. However, when I use a C++ file containing the required function I get an error.
The error says: Undefined symbol C_Irq_Handler (referred from lpc32x0.o)
How can I call the function from the C++ file?
Thanks for your help.
This is a standard C/C++ FAQ question.
You have to do something like:
extern "C" void myfunction(int);
to inform the C++ compiler that it should call a C function, and not a C++ function. How else would the C++ compiler be able to know that you are mixing C and C++ code?
To be type safe, C++ augments the symbol names with data type information, so a call to a C++ function creates a reference to the augmented name - and the linker will then look for this symbol, instead of just the function name. The use of name mangling allows you to have a function my_func(int) and another function my_func(float).
Thank you very much. I handled the problem with your help.
Have a nice day.