I'm trying to understand where all the code comes from that Arduino compiles. I may have some preconceived notions about how it all ties together.
First, let me say, I know what directives are. I know what include does. I can write my own classes, structures etc. I know that in order to use certain functions and classes the correct h file must be included. I know where the core h/cpp files are located.
What I don't understand is why there are some classes like Serial which do not require an include directive to work. I assume that Serial is part of the "core" and it's being told somewhere outside the sketch, to be included. But, I can't find the class in the cores folder. So...
Is the Serial class in a text file (h/cpp) somewhere or is it already precompiled in a dll somewhere or?
Is Serial considered part of the "core?" I ask because I can't find it in any of the files in the cores folder.
I'm still very much a beginner, or occasional dabbler with Arduino. One of my first observations, is that in making things simple for absolute noobs, the ide does some things "under the covers" that can cause a great deal of head scratching.
Perhaps being a tiny bit further down that road, I can tell you that the ide does not compile your .ino file, at least not directly - it creates a .cpp file from it and compiles that. On my windows system that .cpp file, together with a whole lot of other files, is located in
C:\Users\ozcar\AppData\Local\Temp\build-some-great-long-name.tmp\
but your mileage, or location, may vary.
If I look at one of those generated .cpp files, I can see lines from my .ino file, but I also see a line #include "Arduino.h"
That might be a part the answer you are looking for.
I also note some other additions to the .cpp file, like a whole bunch of "forward" declarations for functions defined in the .ino as well as #line directives.
Is the Serial class in a text file (h/cpp) somewhere or is it already precompiled in a dll somewhere or?
Is Serial considered part of the "core?" I ask because I can't find it in any of the files in the cores folder.
Look again at how Serial is used - it is NOT a class, but an instance of a class. What class, depends on which board you're running on. On some boards, probably most, it will be an instance of HardwareSerial, on other boards (Leonardo, Due, etcl) it will be an instance of SerialUSB, or some other class. All they have in common is all inherit from the Stream class.