I am developing a ML system based on Cortex-M4 in C language and combined tensorflow packages (https://github.com/tensorflow/tflite-micro) to my C project.
This package is writen in C++11. So, I use ARM Compiler V6.14 to build my C project.
Becuase Tensorflow package was writen in CC File not Cpp file so that Keil seems to reocognize CC file as C file, and it led to compiling error. So, I tried to converted all CC file in Tensorflow Packages to Cpp file, and Keil finally could build all of the Tensorflow Packages files in my project.
I want to know is there any way to let Keil MDK v5.37 recognize CC file as Cpp file? And I don't need to manually convert all CC file to Cpp File.
Thanks for your help!
Hello,
The `-xc++` option can be used to force C++:https://developer.arm.com/documentation/100748/0614/Using-Common-Compiler-Options/Selecting-source-language-options
If you do not wish to edit your project/makefile, you can use the environment variable `ARMCOMPILER6_CLANGOPT` to add this option automaticallyhttps://developer.arm.com/documentation/100748/0614/Supporting-reference-information/Toolchain-environment-variables
Aside, is there a reason you are using Arm Compiler 6.14? MDK 5.37 is supplied with Arm Compiler 6.18?
Just due to try different solution. The V6.18 is usable in my project.
Can you show an exampe for using the environment variable ARMCOMPILER6_CLANGOPT to force treating all CC file as Cpp in my project?
I have no idea to implement such operation.
Just add that one value to the environment variable, and it will be appended to the command line used by the compiler (you will likely need to restart MDK).
Ensure that `-xc` is not in the MDK command like, as that would over-write this setting.
My project and environment settings:
It seems that Keil is still treating CC file as C file, so there are syntax errors happened. (I have tried to restart my computer.)
What did you mean: "Ensure that `-xc` is not in the MDK command like"
I see '-xc- in the above `C/C++ (AC6)` screenshot, in the Compiler control string.Can you add `-xc++` into the Misc Controls section, which should over-ride that, as it would be added after -xc on the command line (the latter specified option takes preference).
Now, there is another problem while compiling C file.
=> error: invalid argument '-std=c99' not allowed with 'C++'
Should I change the Language C option?
I tried to select Language C option as <default>.
It seems that CC file could be compiled as C++, but it made influence and throw warning and error to some C file in my project (I guess that is caused by different syntax becasue now the whole project is treating as C++ project?).
[Update]
I found a solution that we can set the target CC files as C++ file, and then the compiler is able to treat the CC files as C++ file and compile with C++ default settings.