This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTX error L6218E in C++

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

Parents
  • 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++.

Reply
  • 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++.

Children
  • 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.