Maybe knowing what Arduino does will help
To my knowledge (but I'm not an expert in Arduino)
Arduino
-copies files to temp folder
-preprocesses the .ino file to generate a 'good' .cpp file.
for this it adds basic include files, forward declarations of functions and maybe something else.
(I never have done it but the generated file can be checked as it is stored in temp folder.)
-scans files for included libraries
If all is prepared
Arduino builds hex file with GCC.
There are two potential annoying issues:
one minor is: If one edits library files, Arduino seems to compile always the whole library and not the file one has changed.
another issue is that the conversion from ino to cpp can sometimes have undesired side effects
This can easily be avoided by having a complete empty .ino file and an additional .c or .cpp which setup() and loop()
eg. adding to sketch folder
myApp.c
Code:
#include "Arduino.h"
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
or myApp.cpp
Code:
#include "Arduino.h"
extern "C" {
void setup(void);
void loop(void);
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
The only difference with respect to Arduino's .ino approach is that the .c/ .cpp files must be properly programmed in c/c++ (include files, forward declarations of functions, etc.)
I prefer the .cpp version as it lets me use the standard Serial class fo printouts. Also with this trick I can switch from Arduino IDE to eclipse or viusual micro forward and backward.
I use Arduino to make sure that my program can be compiled by other Teensy users, but I usually program with eclipse IDE.