Go Down

Topic: Any documentation available on IDE pre-processor? (Read 1 time) previous topic - next topic

Nicko

Jul 15, 2010, 11:13 am Last Edit: Jul 15, 2010, 11:14 am by nickds1 Reason: 1
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

PaulS

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.

wayoda

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: [Select]

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

laxman

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

Go Up