Extremely Simple Program Won't Compile

89 views Asked by At

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.

1

There are 1 answers

2
nhg On BEST ANSWER

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.