Hi everyone! I am using MDK-ARM Lite Edition / uVision V5.22.0.0 and i am developing for a STM32F446 microcontroller. I have a project consisting of *.c and *.h files that can be compiled without any problem. Now i am trying to add one cplusplus file and one matching header file (MyClass.cpp and MyClass.h) to this existing project. These two files contain the definition and the source code of my class. When i include the header file in my main.c file (#include "MyClass.h"), i receive the following error message when i try to compile my project again: "MyClass.h(6): error: #20:identifier "class" is undefined"
The source code of MyClass.cpp and MyClass.h should be ok because they can be compiled in an other project (also using MDK-ARM Lite Edition / uVision V5.22.0.0 ).
I am well are aware that a plain C compiler doesn't know the meaning of "class".
And i know "Google" but i cannot find the right magic words for getting a sufficient answer from that guy... :)
Crosschecked the Keil forum also without any luck.
In the project C/C++ settings i tried: > disable C99 mode ===> no change, same error message > --cpp and --cpp_compat ===> no change, same error message > --gnu
I just want to tell MDK-ARM Lite Edition / uVision V5.22.0.0: Please doen't use the C compiler, please use the C++ compiler, in hope that the compiler will recognize the C++ keyword "class".
Can anyone please give my a hint? Thanks in advance Tobi
Yes - not too good to explicitly request a C language standard when at the same time you want to build the file with the C++ compiler.
Best is to select a "correct" file extension, so the tools autodetects the file type. Next best is to configure the project and specify the correct build tool for each source file.
The language standards flags shouldn't be used to specify C or C++, but instead control what generation of the language, and possibly how strict you want the compiler to be.