简体   繁体   English

gcc C ++链接器使“'X'类型与原始声明不匹配”错误?

[英]gcc C++ Linker make “type of 'X' does not match original declaration” an error?

How do I make the following linker warning about a wrong extern declaration an error? 如何使以下链接器警告有关错误的extern声明为错误? I am compiling & linking with gcc version 4.8.3 Sourcery CodeBench 我正在编译和链接gcc版本4.8.3 Sourcery CodeBench

uilding target: xxxxx.elf Invoking: Cross ARM C++ Linker arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -flto -g3 -T "..\\config\\stm32f4ems\\STM32F407xG_CCM.ld" -Xlinker --gc-sections -Wl,-Map,"rusefi.map" -Wl,-Map,"rusefi.map" -mcpu=cortex-m4 -mthumb -g3 .... uilding目标:xxxxx.elf调用:Cross ARM C ++链接程序arm-none-eabi-g ++ -mcpu = cortex-m4 -mthumb -mfloat-abi = softfp -mfpu = fpv4-sp-d16 -O0 -fmessage-length = 0- ffunction-sections -fdata-sections -flto -g3 -T“ .. \\ config \\ stm32f4ems \\ STM32F407xG_CCM.ld” -Xlinker --gc-sections -Wl,-Map,“ rusefi.map” -Wl--Map,“ rusefi.map“ -mcpu = cortex-m4 -mthumb -g3...。

xxx.cpp:584:21: warning: type of 'afrMap' does not match original declaration [enabled by default] xxx.cpp:584:21:警告:“ afrMap”的类型与原始声明不匹配[默认启用]

extern fuel_Map3D_t afrMap; extern fuel_Map3D_t afrMap;

I would like this to not succeed so that I do not miss the issue again. 我希望这不会成功,这样我就不会再错过这个问题了。

Try to use the flag -Werror 尝试使用标志-Werror

From this link : 从此链接

-Werror
Make all warnings into errors.

EDIT: If you want to be more specific, you can use 编辑:如果您想更具体,可以使用

-Werror=
Make the specified warning into an error. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM