Coming from another Atmel IDE - Imagecraft, I don't understand how this Arduino Sketch
works.
Example: If I open /Arduino/examples/07.display/bargraph, I get an Arduino sketch file which when opened contains the .c source code for the project. But where is the .c file? I can't find it anywhere?
I am trying to set up a new project with code from a .git repository. I want to do it right but this hidden source code is a problem for me. How do I back it up or move it to another compiler IDE?
This doesn't explain where the source files are. In the example above where is bargraph.c? I am not trying to use bargraph.c, I just want to know where sketch stores source files like this.
C is a transportable language with some caveats. Nevertheless I should be able to take any C source file and open it even on a DOS 1.0 text editor or NOTEPAD. It should not be buried in some proprietary wrapper if that is what sketch is?
Hi @adelle. The sketch file is the source file. There is no hidden .c file.
When you initiate a compilation in the Arduino IDE (or other Arduino development software), the .ino files of the sketch are put through a "sketch preprocessing" operation that converts them into valid C++ (NOTE: C++, not C) code:
If there are multiple .ino files in the sketch, concatenate them into a single file, starting with the file that matches the sketch folder name, followed by the rest in alphabetical order.
Add #include <Arduino.h> at the top of the file, if an #include directive for that file doesn't already exist. Arduino.h contains declarations of the standard Arduino core library API, which is documented in the Arduino Language Reference.
Insert automatically generated function prototypes for any function that doesn't already have one.
Add #line directives to make warning/error messages still match the original sketch files.
There is more information on sketch preprocessing here:
If you are just wondering where the code is for the Arduino Examples then yeah, they are kind of hidden away but it doesn't really matter. Once you have the example open, go up to the File menu and select the Save option. This will let you name it and place wherever you want, including a git repository folder that you have already setup on your machine.