Eclipse CDT错误:“Symbol'XXX'无法解析” [英] Eclipse CDT error: "Symbol 'XXX' could not be resolved"

查看:254
本文介绍了Eclipse CDT错误:“Symbol'XXX'无法解析”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌入式C项目,在控制台上使用make构建和运行,但Eclipse CDT给我错误。



在main.c中,函数使用宏,APP_BUTTON_INIT:

  static void buttons_init(void)
{
static app_button_cfg_t buttons [ ] =
{
{SIGNAL_ALERT_BUTTON,false,NRF_GPIO_PIN_NOPULL,button_event_handler},
{BONDMNGR_DELETE_BUTTON_PIN_NO,false,NRF_GPIO_PIN_NOPULL,NULL}
};

APP_BUTTON_INIT(buttons,sizeof(buttons)/ sizeof(buttons [0]),BUTTON_DETECTION_DELAY,false);
}

APP_BUTTON_INIT宏在app_button.h中定义如下:

  #define APP_BUTTON_INIT(BUTTONS,BUTTON_COUNT,DETECTION_DELAY,USE_SCHEDULER)\ 
do \
{\
uint32_t ERR_CODE = app_button_init((BUTTONS),\
(BUTTON_COUNT),\
(DETECTION_DELAY),\
(USE_SCHEDULER)?app_button_evt_schedule:NULL); \
APP_ERROR_CHECK(ERR_CODE); \
} while(0)

错误是

 符号'app_button_evt_schedule'无法解析

但是该功能在相同的头文件app_button.h中进一步定义:

  static __INLINE uint32_t app_button_evt_schedule (app_button_handler_t button_handler,
uint8_t pin_no)
{
app_button_event_t buttons_event;

buttons_event.button_handler = button_handler;
buttons_event.pin_no = pin_no;

return app_sched_event_put(& buttons_event,sizeof(buttons_event),app_button_evt_get);
}

我试过项目右键 - >索引 - >重建和清理所有档案,没有快乐。我使用Eclipse Kepler SR1与CDT 8.2.1。为什么Eclipse不能看到这个功能?



makefile的第一个操作是这样(这样):

  mkdir _build 
/ Users / Eliot / dev / gcc-arm / bin / arm-none-eabi-gcc-DNRF51822_QFAA_CA -mcpu = cortex-m0 -mthumb - mabi = aapcs -DNRF51 -DBOARD_NRF6310 -DNRF51822_QFAA_CA --std = gnu99 -Wall -Werror -mfloat-abi = soft -DDEBUG -g3 -O0 -I/ Users / Eliot / dev / nrf51822 / Include / ble-I/用户/ Eliot / dev / nrf51822 / Include / ble / softdevice-I/ Users / Eliot / dev / nrf51822 / Include / app_common-I/ Users / Eliot / dev / nrf51822 / Include / ble / ble_services ../-I/ Users / Eliot / dev / nrf51822 / Include-I/ Users / Eliot / dev / nrf51822 / Include / gcc-I/ Users / Eliot / dev / nrf51822 / Include / ext_sensors -M ../main.c -MF_build / main.d-MT _build / main.o

我的CDT项目配置的屏幕截图包括,符号和工具链在这里:



https:/ /dl.dropboxusercontent.com/u/12173473/screenshot_cdt_includes.png
https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_symbols.png
https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_toolchain.png



我没有使用工具链,因为我的项目开始是硬件制造商(Nordic Semiconductor)的CDT项目示例,该项目也没有配置工具链。说实话,我怀疑CDT找到了正确的gcc可执行文件。

解决方案

自我回答。在Eclipse中配置的正确的工具链没有运行是问题。对于使用cross gcc的ARM开发,这个Eclipse插件解决了我的问题,一般看起来很有前途。它为您提供整个工具链的Eclipse项目设置,意味着您可以修改makefile。



http://gnuarmeclipse.github.io


I have an embedded C project that builds and runs just fine using make on the console, but Eclipse CDT is giving me errors.

In main.c, this function uses a macro, APP_BUTTON_INIT:

static void buttons_init(void)
{
    static app_button_cfg_t buttons[] =
    {
        {SIGNAL_ALERT_BUTTON,           false, NRF_GPIO_PIN_NOPULL, button_event_handler},
        {BONDMNGR_DELETE_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, NULL}
    };

    APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false);
}

The APP_BUTTON_INIT macro is defined in app_button.h like this:

#define APP_BUTTON_INIT(BUTTONS, BUTTON_COUNT, DETECTION_DELAY, USE_SCHEDULER)                     \
do                                                                                             \
{                                                                                              \
    uint32_t ERR_CODE = app_button_init((BUTTONS),                                             \
                                        (BUTTON_COUNT),                                        \
                                        (DETECTION_DELAY),                                     \
                                        (USE_SCHEDULER) ? app_button_evt_schedule : NULL);     \
    APP_ERROR_CHECK(ERR_CODE);                                                                 \
} while (0)

The error is

Symbol 'app_button_evt_schedule' could not be resolved

But that function is defined further down in the very same header file, app_button.h:

static __INLINE uint32_t app_button_evt_schedule(app_button_handler_t button_handler,
                                             uint8_t              pin_no)
{
    app_button_event_t buttons_event;

    buttons_event.button_handler = button_handler;
    buttons_event.pin_no         = pin_no;

    return app_sched_event_put(&buttons_event, sizeof(buttons_event), app_button_evt_get);
}

I've tried Project right click -> Index -> Rebuild and Freshen all files, no joy. I'm using Eclipse Kepler SR1 with CDT 8.2.1. Why can't Eclipse see this function?

The first operation of the makefile is this (this works):

mkdir _build
"/Users/Eliot/dev/gcc-arm/bin/arm-none-eabi-gcc" -DNRF51822_QFAA_CA -mcpu=cortex-m0 -mthumb -mabi=aapcs -DNRF51 -DBOARD_NRF6310 -DNRF51822_QFAA_CA --std=gnu99 -Wall -Werror -mfloat-abi=soft -DDEBUG -g3 -O0 -I"/Users/Eliot/dev/nrf51822/Include/ble" -I"/Users/Eliot/dev/nrf51822/Include/ble/softdevice" -I"/Users/Eliot/dev/nrf51822/Include/app_common" -I"/Users/Eliot/dev/nrf51822/Include/ble/ble_services" -I"../" -I"/Users/Eliot/dev/nrf51822/Include" -I"/Users/Eliot/dev/nrf51822/Include/gcc" -I"/Users/Eliot/dev/nrf51822/Include/ext_sensors" -M ../main.c -MF "_build/main.d" -MT _build/main.o

Screenshots for my CDT project config for includes, symbols and the tool chain are here:

https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_includes.png https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_symbols.png https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_toolchain.png

I'm not using a toolchain because my project started out as the sample CDT project from the hardware manufacturer (Nordic Semiconductor) and that project also had no toolchain configured. To be honest, I doubt CDT is finding the right gcc executable.

解决方案

Self-answering. Running around without a proper toolchain configured in Eclipse was the problem. For ARM development using cross gcc, this Eclipse plugin fixed my problem and looks promising in general. It gives you Eclipse project settings for the whole toolchain and means you can ditch your makefiles.

http://gnuarmeclipse.github.io

这篇关于Eclipse CDT错误:“Symbol'XXX'无法解析”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆