Skip to main content
CSand
Associate III
September 23, 2019
Question

Error : unknown type name 'class'

  • September 23, 2019
  • 1 reply
  • 11892 views

Hello,

I am migrating from Arduino to CubeIDE looking to have better IDE and better performance code. Migration was rather challenging but managed to go ahead. Still there is one new issue I have.

I created a C++ project using CubeMX but I get this error and others related to classes. Even I create C++ project the main file still has .C extention. To resolve I tried:

  • Change main.c file extension to cpp
  • Used File->New->Convert to C/C++

Still the error remains.

I expect is a newbie question, I am sorry. Could anyone help?

Thanks

This topic has been closed for replies.

1 reply

RSemm
Visitor II
September 14, 2020

This happens when you include an header with a class from a C- file.

C cannot call or use Classes.

When you write your own intermidiate mainCpp-funciton the main.c can call this mainCPP-function form a mainCpp.cpp. The mainCpp.h may not contain any classes.

Then you can include and use all Class-Headers from mainCpp.cpp