Pages: [1]   Go Down
Author Topic: Any documentation available on IDE pre-processor?  (Read 1044 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Is there any documentation available of how the Arduino IDE pre-parses the C++ code to generate function prototypes etc. before the actual avr-gcc compilation phase - by documentation I don't mean generalities - I'm looking for specifics and detail... preferably the actual algorithm.

The reason I ask is that I have singleton classes with embedded static member functions - these happily compile in AVRstudio with avr-gcc (same version), but fail with obtuse messages in the Arduino environment.

Alternatively, is there a way of keeping the intermediate file produced after the pre-processor has had its way so that I can see more clearly what its up to?

Thanks
« Last Edit: July 15, 2010, 04:14:19 am by nickds1 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino IDE source code and avr-gcc compiler source code are available. It's likely, though, that the difference you are seeing is in the compiler options passed the pre-processor.

There are ways to turn on more compiler output, by making changes in the preferences file (and keyboard shortcuts in 0018). Perhaps that would give you a clue.

You might also post the code and pre-processor/compiler output. Perhaps someone here will recognize what the problem is.
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
the code for the preprocessor is here:
http://code.google.com/p/arduino/source/browse/trunk/app/src/processing/app/preproc/PdePreprocessor.java

Could you post your class code (or better an abbreviated example)?

You find the preprocessed output in the build dir of the sketch.
Compile the sketch while holding down the Shift-Key.
In the generated output you should see something like
Code:
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=18 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/home/wayoda/sketchbook/libraries/DogLcd -I/home/wayoda/sketchbook/libraries/DogLcd/utility /home/wayoda/sketchbook/libraries/DogLcd/DogLcd.cpp -o/tmp/build5471887903982210197.tmp/DogLcd/DogLcd.cpp.o
avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=18 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/home/wayoda/sketchbook/libraries/DogLcd /tmp/build5471887903982210197.tmp/blues.cpp -o/tmp/build5471887903982210197.tmp/blues.cpp.o
avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /tmp/build5471887903982210197.tmp/blues.cpp.elf /tmp/build5471887903982210197.tmp/DogLcd/DogLcd.cpp.o /tmp/build5471887903982210197.tmp/blues.cpp.o /tmp/build5471887903982210197.tmp/core.a -L/tmp/build5471887903982210197.tmp -lm
avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build5471887903982210197.tmp/blues.cpp.elf /tmp/build5471887903982210197.tmp/blues.cpp.eep
avr-objcopy -O ihex -R .eeprom /tmp/build5471887903982210197.tmp/blues.cpp.elf
What you are looking for is the
/tmp/build5471887903982210197.tmp/
part. This is the directory (starting with /build) where the preprocessed files are written and compiled files are saved temporarily.
The file named <NameOfYourSketch>.cpp contains the preprocessed code.

The directory (and files) are deleted when the IDE exits, so you have to look at the files while the IDE is still running.
Eberhard
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You find the preprocessed output in the build dir of the sketch
Logged

Pages: [1]   Go Up
Jump to: