Pages: [1]   Go Down
Author Topic: Arduino IDE's -- 'C' code generation and intermediate files  (Read 718 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 117
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to somehow intercept the IDE's build process, to isolate the intermediate 'C' files which use the avr-libc (and other Arduino libs), to study ?
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why bother when it's all open source and downloadable?

http://www.nongnu.org/avr-libc/

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

0
Offline Offline
Full Member
***
Karma: 0
Posts: 117
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Should have worded my requirement and motivation more clearly.
What I'd like to do, while I am learning to program directly with avr-libc, is to compare / try-understand the Arduino (Java/C++ based) converted to C code, generated by IDE as a result of compile+verify step.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6645
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The pre-processed files generated by the Arduino IDE show up in the (java-determined) tmp directory that you can see if you turn on verbose compilation in the Arduino preferences, and you can look at them there.

Note that there is generally quite a bit less pre-processing than you seem to expect.  An arduino sketch is C++ code, and the main thing that happens is that the IDE generates a set of function prototypes at the beginning of the code, before passing it to a real C++ compiler.  There is no "conversion to C" step.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Should have worded my requirement and motivation more clearly.
What I'd like to do, while I am learning to program directly with avr-libc, is to compare / try-understand the Arduino (Java/C++ based) converted to C code, generated by IDE as a result of compile+verify step.

There's no conversion to C. The compiler accepts C++ directly and there's no Java.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This article was helpful when I had the same question:

http://arduino.cc/en/Hacking/BuildProcess

The short of it being, the IDE tidies up the sketch by merging all tabs into one file, adding prototypes, including library files in the build, and so on.  But that's about it.  Most of the "magic" is actually just C++ wrappers to add friendly functions and defines so you don't have to know so much about the hardware registers.

Moving to AVR C is fairly easy to do with Atmel Studio.  You can even import the Arduino libs and write your programs in a "real" C++ IDE.  That's actually a good way to go, because IMO, the Arduino IDE is really a horrible code editor, but the platform is so handy. smiley-razz
Logged

Pages: [1]   Go Up
Jump to: