2020-05-28 12:32 AM
I'm trying to import an Arduino C++ library into an STM32F4 project. I set the project to be a C++ one while I was creating it. I've also made the necessary code changes needed for the STM32. However, while compiling I'm getting the following errors. Can anyone please let me know how I can resolve this? I've also attached the library files here.
In file included from ../Core/Src/main.c:27:0:
../Core/Inc/PID_V1.h:5:1: error: unknown type name 'class'
class PID {
^~~~~
../Core/Inc/PID_V1.h:5:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
class PID {
^
make: *** [Core/Src/subdir.mk:47: Core/Src/main.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j4 all" terminated with exit code 2. Build might be incomplete.
11:05:41 Build Failed. 4 errors, 0 warnings. (took 6s.826ms)
2020-05-28 12:53 AM
In file included from ../Core/Src/main.c:27:0:
While your file is still called "main.c" then it is still a C file, and so can't cope with "C++ only" things like classes.
Try renaming that file to main.cpp and do whatever else is necessary for your IDE to look for main.cpp not main.c?
Hope this helps,
Danish
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.