c++classstm32cubeide

Extremely Simple Program Won't Compile


Just trying to make an SPI class. Here is my code:

#ifndef SRC_SPI_H_
#define SRC_SPI_H_

class SPI {

};

#endif

Here are the errors:

expected '=', ',', ';', 'asm' or '__attribute__' before '{' token SPI.h /ICM_Tester/Core/Src line 4

unknown type name 'class' SPI.h /ICM_Tester/Core/Src line 4

I have tried rebuilding, and I made sure this is a C++ project. Seems like a compiler issue, but I've been banging my head against a wall trying to figure this out. Please help.


Solution

  • I finally figured it out. Creating a "C++ project" in STM32CubeIDE apparently isn't enough. I had to manually rename main.c -> main.cpp and now it works.