C2059 Error Using extern "C" in .C Source Files

C2059 Error Using extern "C" in .C Source Files


The information to this article applies to:
The Microsoft C/C++ Compiler included with: - Microsoft Visual C++, 32-bit Edition, versions 2.0, 2.1, 2.2, 4.0,

     4.1, 5.0

SUMMARY
Use of "extern "C"" in source files that have a .C extension causes error C2059, and results in this error message:

   error C2059:syntax error:'string'

CAUSE
In the C language, the string-literal "C" is not recognized. It is used in C++ to prevent name decoration.

RESOLUTION
Remove the string-literal "C" in extern declarations, or use the following in the function declaration:


   #ifdef __cplusplus
      extern "C"
   #endif 

Build started: Project: noye01 *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling list.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\list.c: 0 warnings, 1 error compiling heap_4.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos_port\MemMang\heap_4.c: 0 warnings, 1 error compiling timers.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\timers.c: 0 warnings, 1 error compiling tasks.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\tasks.c: 0 warnings, 1 error compiling main.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\User\main.c: 0 warnings, 1 error compiling port.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos_port\RVDS\ARM_CM3\port.c: 0 warnings, 1 error compiling queue.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\queue.c: 0 warnings, 1 error compiling event_groups.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\event_groups.c: 0 warnings, 1 error compiling croutine.c... ..\User\FreeRTOSConfig.h(184): error: #5: cannot open source input file "trcRecorder.h": No such file or directory #include "trcRecorder.h" ..\freertos\croutine.c: 0 warnings, 1 error ".\Objects\noye01.axf" - 9 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:01
11-07
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'E:\ARM\ARM\ARMCC\Bin' Build target 'gaige' compiling stm32g4xx_ll_adc.c... compiling tim.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/tim.c: 0 warnings, 1 error compiling stm32g4xx_it.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/stm32g4xx_it.c: 0 warnings, 1 error compiling gpio.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/gpio.c: 0 warnings, 1 error compiling main.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/main.c: 0 warnings, 1 error compiling adc.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/adc.c: 0 warnings, 1 error compiling stm32g4xx_hal_gpio.c... compiling stm32g4xx_hal_flash.c... compiling stm32g4xx_hal_flash_ramfunc.c... compiling stm32g4xx_hal_msp.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ../Core/Src/stm32g4xx_hal_msp.c: 0 warnings, 1 error compiling stm32g4xx_hal_rcc_ex.c... compiling stm32g4xx_hal_flash_ex.c... compiling stm32g4xx_hal.c... compiling stm32g4xx_hal_adc_ex.c... compiling stm32g4xx_hal_adc.c... compiling stm32g4xx_hal_rcc.c... compiling stm32g4xx_hal_exti.c... compiling stm32g4xx_hal_dma.c... compiling stm32g4xx_hal_dma_ex.c... compiling stm32g4xx_hal_pwr.c... compiling switch.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" SWITCH\switch.c: 0 warnings, 1 error compiling stm32g4xx_hal_pwr_ex.c... compiling font_lib_port.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" ..\..\HAL_407_TFT\code\font_lib_port.c: 0 warnings, 1 error compiling lcd_st7789.c... ../Core/Inc/main.h(33): error: #5: cannot open source input file "font_lib.h": No such file or directory #include "font_lib.h" TFT\lcd_st7789.c: 0 warnings, 1 error compiling system_stm32g4xx.c... compiling stm32g4xx_hal_cortex.c... compiling stm32g4xx_hal_tim_ex.c... compiling stm32g4xx_hal_tim.c... "GAIGE\GAIGE.axf" - 9 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:15
最新发布
12-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值