.ino file to .cpp file

Status
Not open for further replies.

izyankarim

New member
hi,
Im currently using your product teensy 3.1.
I need help from pjrc to guide me to use teensy board and program it using c++ instead of arduino.
 
arduino is c++. Arduino is just a set of libraries and a trivial main() that calls setup() and loop().

If you search on the forums here, you'll find instructions for locating a makefile, using alternative development environments, etc.
 
hi,
Im currently using your product teensy 3.1.
I need help from pjrc to guide me to use teensy board and program it using c++ instead of arduino.

Simply change .ino to .cpp
If you NOT using Arduino IDE then you must only include the necessary include files.
for example
Code:
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

#include "kinetis.h"
#include "core_pins.h"

#include "usb_serial.h"
covers a lot of applications

I typically keep the setup(), loop() structure of Arduino, and added my own main, wich is simply
Code:
extern void setup(void);
extern void loop(void);

int main(void)
{  setup();
    while(1) loop();
    return 0;
}

this way, I can quickly post arduino compatible examples in case I need help from others on the forum.
Even if I do not use Arduino for my own development (I use a makefile system) , arduino/teensyduino is convenient for quick tests, and is a common environment for all of us.
 
arduino is c++. Arduino is just a set of libraries and a trivial main() that calls setup() and loop().

Arduino also does some simple pre-processing, mainly to add #include <Arduino.h> at the top, and the create function prototypes for every function you create in the .ino files. Simple stuff, but it does help beginners.

Arduino also parses which #include lines you've put in the .ino file, to figure out which libraries need to be compiled into your project. Most other environments have ways for you to specify which libs. Arduino tries to do it automatically, so there's fewer steps to set up.

I recommend using File > Preferences to turn on verbose info while compiling. Then you can see the actual command lines Arduino uses when compiling. It writes a converted copy of your .ino file as a .cpp file in a temp dir. Comparing the original .ino to the generated .cpp can help you understand the extra little things Arduino is doing.
 
Status
Not open for further replies.
Back
Top