Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
To clarify the question about libraries ...
You do need to put into the .ino file an include for any libraries used in the project. For example:
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
This effectively triggers the Arduino build process to link those libraries into the final executable file.
Related, my reply in this thread: Classes and objects: how many and which file types do I actually need to use them? Classes and objects: how many and which file types do I actually need to use them?
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
To clarify the question about libraries ...
You do need to put into the .ino file an include for any libraries used in the project. For example:
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
This effectively triggers the Arduino build process to link those libraries into the final executable file.
Related, my reply in this thread: Classes and objects: how many and which file types do I actually need to use them?
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
To clarify the question about libraries ...
You do need to put into the .ino file an include for any libraries used in the project. For example:
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
This effectively triggers the Arduino build process to link those libraries into the final executable file.
Related, my reply in this thread: Classes and objects: how many and which file types do I actually need to use them?
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
To clarify the question about libraries ...
You do need to put into the .ino file an include for any libraries used in the project. For example:
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
This effectively triggers the Arduino build process to link those libraries into the final executable file.
Related, my reply in this thread: Classes and objects: how many and which file types do I actually need to use them?
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing
To clarify the question about libraries ...
You do need to put into the .ino file an include for any libraries used in the project. For example:
#include <Wire.h>
#include <SPI.h>
#include <EEPROM.h>
This effectively triggers the Arduino build process to link those libraries into the final executable file.
Related, my reply in this thread: Classes and objects: how many and which file types do I actually need to use them?
Make a new tab in the IDE (top RH corner) with a xxx.cpp file name. Put your code in that. Leave the .ino file blank. Then it will compile. You need to add:
#include <Arduino.h>
... to the start of the .cpp file.
More information: How to avoid the quirks of the IDE sketch file pre-preprocessing