"Error compiling for board Arduino Mega 2560"

Hi,

Tried to compile some code this morning for my current project, and I got this error.

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Users\[User]\Documents\GitHub\thermocoupe_test\sketch_nov03a\sketch_nov03a.ino:3:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h:72:1: error: expected initializer before 'class'

 class SPISettings {

 ^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I've got no clue what I'm looking at, when I saw this compiling error online, nothing seemed relevant to my issue.

I can show the actual code if that's necessary.

stitch,

The obvious guess is that whatever header is included right before SPI.h left the semicolon off the end of the class declaration. If it isn’t that then yes, you should post the code. You should always post the code. There’s never ever a time where posting the code is a bad idea.

Delta_G:
The obvious guess is that whatever header is included right before SPI.h left the semicolon off the end of the class declaration. If it isn’t that then yes, you should post the code. You should always post the code. There’s never ever a time where posting the code is a bad idea.

My best guess was needing some SPI related library, but isn’t that supposed to already come with the IDE?

Anyway, I’m trying to learn how to use an Adafruit thermocouple “amplifier” and get it to talk with a third party screen from 4D Systems, so it’s currently a hodgepodge of the example code Adafruit provided and my best guess to send that data to my screen.

#include<genieArduino.h>
Genie genie
#include<SPI.h>
#include"Adafruit_MAX31855.h"

#define MAXDO  3
#define MAXCS  4
#define MAXCLK 5

Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);

void setup()
{
  Serial.begin(9600);
  genie.Begin(Serial);
  while (!Serial) delay(1);
  Serial.println("MAX31855 test");
  delay(2500)
}

void loop()
{
  Serial.print("Internal Temp - ");
  Serial.println(thermocouple.readInternal());

  double c= thermocouple.readCelsius();
  if (isnan(c)) {
    Serial.println("Something wrong with thermocouple!");
  } else {
    Serial.print("C = ");
    Serial.println(c);
  }
  genie.WriteObject(GENIE_OBJ_GAUGE, 0x00, "readInternal")
  genie.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 0x00, "readInternal")
  delay(1000)
}

Missing semi-colon on the second line.

sterretje:
Missing semi-colon on the second line.

Huh, so it doesn't mention that line but as soon as I fixed that it mentions another few I forgot about.

Time to go repeat that mistake another hundred times in the course of my project. Thanks, lol

stitch2k1:
Huh, so it doesn’t mention that line

You could’ve put the required semicolon on the next line, and the compiler would not have cared.

TheMemberFormerlyKnownAsAWOL:
You could've put the required semicolon on the next line, and the compiler would not have cared.

Right. There were lots of things that could have legally come there. It wasn't an error until it got to that class definition and there wasn't a semicolon before it.

One important lesson. Put all the #include stuff at the top together. Don't mix it in with your code.

Delta_G:
One important lesson. Put all the #include stuff at the top together. Don’t mix it in with your code.

As in this

#include<genieArduino.h>
#include<SPI.h>
#include"Adafruit_MAX31855.h"
Genie genie;

instead of this?

#include<genieArduino.h>
Genie genie;
#include<SPI.h>
#include"Adafruit_MAX31855.h"

Yes

A space between the includes and the variable declaration is also nice :wink: