【问题标题】:Eclipse compiles correctly but shows error in 'Problems' viewEclipse 编译正确,但在“问题”视图中显示错误
【发布时间】:2012-01-12 07:27:50
【问题描述】:

控制台输出为:

**** Build of configuration Release for project Timertestnew ****

make all 
Building file: ../main.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"G:\arduino-1.0\hardware\arduino\cores\arduino" -DARDUINO=100 -Wall -Os -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o "main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: Timertestnew.elf
Invoking: AVR C++ Linker
avr-gcc --cref -s -Os -o"Timertestnew.elf"  ./main.o   -lArduinoCore -lm -Wl,-Map,Timertestnew.map,--cref -L"C:\Users\Akhil\workspace\Timertestnew" -mmcu=atmega328p
Finished building target: Timertestnew.elf

Create Flash image (ihex format)
avr-objcopy -R .eeprom -O ihex Timertestnew.elf  "Timertestnew.hex"
Finished building: Timertestnew.hex

Invoking: Print Size
avr-size --format=avr --mcu=atmega328p Timertestnew.elf
AVR Memory Usage
----------------
Device: atmega328p

Program:     620 bytes (1.9% Full)
(.text + .data + .bootloader)

Data:          9 bytes (0.4% Full)
(.data + .bss + .noinit)


Finished building: sizedummy


**** Build Finished ****

“问题”视图输出为:

Description Resource    Path    Location    Type
Symbol 'EEARH' could not be resolved    main.cpp    /Timertestnew   line 15 Semantic Error

eclipse ide在编译时是否可能错误地显示此错误? 我该如何解决这个问题?

【问题讨论】:

    标签: eclipse compiler-construction linker arduino


    【解决方案1】:

    尝试从问题视图中删除该问题标记并重建您的项目(完全,而不仅仅是增量)。如果这样可以解决问题,那么它只是编译器的不一致状态。

    但是,如果它不能解决问题,那么 Eclipse 编辑器可能使用了不同的解析器(用于内容辅助等),它无法处理您的编译器可以处理的问题。对于这种情况,我会查看与错误相关的 C/C++ 编辑器首选项,也许它可以关闭(但是,我不会编程 C/C++,所以我无法告诉您要查找的内容)。

    【讨论】:

      【解决方案2】:

      avr-gcc 编译器使用其-mmcu 命令行参数来确定要包含哪个 IO 头文件(因此符号寄存器定义包括报告的EEARH EEPROM 高地址寄存器)。 Documentation here.

      Eclipse 可能不知道这个“后门”预处理器符号定义(因为它可能使用不同的编译器进行问题检测)。从控制台输出看来,您需要的 IO 头文件是:avr/iom328p.h,它包含在定义 __AVR_ATmega328P__ 预处理器符号时 (see here)。如果你向 Eclipse 提供这个符号,它应该会导致它的编译器选择正确的文件并定义相关的寄存器。

      【讨论】:

        猜你喜欢
        • 2018-07-28
        • 2011-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-23
        • 1970-01-01
        • 1970-01-01
        • 2014-08-27
        相关资源
        最近更新 更多