This is a branch from topic "how to start writing in the end of an existing file? (SD Card)".
IIRC gcc has an option that will tell it to print all defined macros.
Just for the record it is "-E -dM", but as Lee says, not relevant here.
I tried this option in a short program using Atmel Studio 6.2 and got an error (gcc output shown below).
Here is the where I set the gcc option:
This is the program
/* * Blink_Led_1MHz_Clk.c * * Created: 1/17/2016 10:11:21 PM * Author: C * * * ATmega328P on Arduino Nano * 16MHz Ceramic Resonator * Reduce F_CPU to 1MHz */ #define F_CPU 1000000UL #include <avr/io.h> #include <util/delay.h> void Blink4(void) { for (uint8_t i=0; i<4; i++) { PINB = (1<<PINB5); // Toggle PB5 high/low _delay_ms(300); PINB = (1<<PINB5); // Toggle PB5 high/low _delay_ms(300); } } int main(void) { CLKPR = (1<<CLKPCE); // enable clock div change CLKPR = (1<<CLKPS2); // set to div by 16 DDRB |= (1<<PINB5); // set PB5 as output pin while(1) { Blink4(); _delay_ms(1500); } }
This is the GCC Build output:
------ Build started: Project: Blink_Led_1MHz_Clk, Configuration: Debug AVR ------
Build started.
Project "Blink_Led_1MHz_Clk.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Atmel Studio 6.2\Vs\Compiler.targets" from project "E:\_Files\Programming\Atmel_Studio_Projects\_Studio6\AVR\Blink_Led_1MHz_Clk\Blink_Led_1MHz_Clk.cproj" (target "Build" depends on it):
Task "RunCompilerTask"
Shell Utils Path C:\Program Files (x86)\Atmel\Atmel Studio 6.2\shellUtils
C:\Program Files (x86)\Atmel\Atmel Studio 6.2\shellUtils\make.exe all
Building file: .././Blink_Led_1MHz_Clk.c
Invoking: AVR/GNU C Compiler : 4.8.1
"C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-gcc.exe" -x c -funsigned-char -funsigned-bitfields -DDEBUG -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -c -std=gnu99 -E -dM -MD -MP -MF "Blink_Led_1MHz_Clk.d" -MT"Blink_Led_1MHz_Clk.d" -MT"Blink_Led_1MHz_Clk.o" -o "Blink_Led_1MHz_Clk.o" ".././Blink_Led_1MHz_Clk.c"
Finished building: .././Blink_Led_1MHz_Clk.c
Building target: Blink_Led_1MHz_Clk.elf
Invoking: AVR/GNU Linker : 4.8.1
"C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.1061\avr8-gnu-toolchain\bin\avr-gcc.exe" -o Blink_Led_1MHz_Clk.elf Blink_Led_1MHz_Clk.o -Wl,-Map="Blink_Led_1MHz_Clk.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=atmega328p
Blink_Led_1MHz_Clk.o: file not recognized: File format not recognized
collect2.exe(0,0): error: ld returned 1 exit status
make: *** [Blink_Led_1MHz_Clk.elf] Error 1
The command exited with code 2.
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "Blink_Led_1MHz_Clk.cproj" -- FAILED.
Done building project "Blink_Led_1MHz_Clk.cproj" -- FAILED.Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
I appreciate any help you can provide.
Edit: When I build without the "-E -dM" option, there are no build errors and the firmware runs correctly.