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 guys,
I'm suffering from an issue similar to this post:
http://www.keil.com/forum/17963/
Where switching to C++ has caused linker errors due to C/C++ mixing. I followed the same advice, however just the action of adding configuration file RTX_Conf_CM.c to my project causes these errors before I've even included any RTX related files and used any of RTX in my own code.
I have attempted to surround RTX_Conf_CM.c in extern "C" { } to no avail.
Any ideas what I may have to change?
Many thanks
To simplify matters and provide a common code base for this issue, perhaps someone would be able to explain how, for example, it may be possible make the RTX_Blinky demo for the Keil MCB1200 board RTX C++ ready?
As just adding extern "C" doesn't appear to work here either.
Many thanks for any help/advice.
adding configuration file RTX_Conf_CM.c to my project causes these errors
And what would "these errors" actually have been, if it's not too much to ask?
before I've even included any RTX related files and used any of RTX in my own code.
But RTX_Conf_CM.c surely is an RTX-related file, isn't it? And you have included it.
.\Flash\Blinky.axf: Error: L6218E: Undefined symbol mp_stk_size (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol mp_tcb_size (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol mp_tmr_size (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_fifo_size (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_maxtaskrun (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_stackinfo (referred from rt_task.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_flags (referred from hal_cm1.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_trv (referred from rt_system.o). .\Flash\Blinky.axf: Error: L6218E: Undefined symbol os_rrobin (referred from rt_robin.o).
This is from taking the standard RTX_Blinky demo included with MDK 4.60 (in this instance for the Keil MCB1200) and inserting the --cpp flag. I've attempted to wrap all included headers in extern "C" {} however this has no impact on the errors.
With regards to not including RTX_Conf_CM.c what I mean is it's isolated from my own code but compiled as part of the project.
However, I figure an example that everyone has a copy of is simpler than trying to list my own code.
Cheers
Note that extern "C" { ... } is great for header files.
But if you include a C source file in a C++ project, you should normally set up that specific file to compile as C - not C++ in the project options, if the tools isn't correctly managing to figure that out directly from the file extension.
If you build a C file with listing enabled, you can look at the assembler listings for that file to verify if the bindings for the functions are using the proper function names for C API, or if you see mangled function names as used for C++.
You were exactly correct, the compiler wasn't recognising the .c extension as being C only and was compiling as C++ with extern "C" having no effect. Setting the --c99 flag on the file locally overrode this setting.
For the record I don't think the issue was directly with this file, however it goes on to include RTX_lib.c that unlike the RTL.h header doesn't have provisions for extern "C" in the event of C++ compilation.
Many thanks for all the help.