Skip to main content
Arduino

Return to Answer

replaced http://arduino.stackexchange.com/ with https://arduino.stackexchange.com/
Source Link

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?

Explained about library includes.
Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125

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?

Source Link
Nick Gammon
  • 38.9k
  • 13
  • 69
  • 125

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

AltStyle によって変換されたページ (->オリジナル) /