简体   繁体   English

“错误:'volatile'之前的预期主表达式”

[英]“error: expected primary-expression before 'volatile'”

I'm trying to compile NRF driver with MinGW 4.8.2. 我正在尝试使用MinGW 4.8.2编译NRF驱动程序 I'm getting this error: 我收到此错误:

In file included from 在包含的文件中

b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/device/nrf51.h:119:0,
                 from b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/softdevice/s130/headers/nrf_soc.h:50,
                 from b:/nrfdriver/pc-ble-driver-0.5.0/driver/inc_override/nrf_soc.h:21,
                 from b:/nrfdriver/pc-ble-driver-0.5.0/driver/inc_override/app_util_platform.h:26,
                 from b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/drivers_nrf/uart/app_uart.h:27,
                 from b:\nrfdriver\pc-ble-driver-0.5.0\driver\src\app_uart_pc.c:13:
C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/4.8.2/include/xmmintrin.h:
In function 'void _mm_setcsr(unsigned int)':
b:/nrfdriver/sdk/nRF51_SDK_8.1.0_b6ed55f/components/toolchain/gcc/core_cm0.h:164:21:
error: expected primary-expression before 'volatile'    #define   __I 
volatile             /*!< Defines 'read only' permissions   */
                     ^ driver\CMakeFiles\s130_nrf51_ble_driver.dir\build.make:297: recipe for
target 'driver/CMakeFiles/s130_nrf51_ble_driver.dir/src/app_uart_pc.c
.obj' failed

Error comes from this line: 错误来自此行:

#define   __I     volatile             /*!< Defines 'read only' permissions                 */

How can such a simple #define lead to a compiler error and any idea how I should fix that? 这样简单的#define如何导致编译器错误,以及如何解决该错误的任何想法? (upgrading the compiler is not an option as this version of the driver is supposed to be built with this version of MinGW). (升级编译器不是一个选择,因为该版本的驱动程序应该使用此版本的MinGW构建)。

Note that the driver is meant to be built in 32bits and I'm trying to build it targetting 64bits, dunno if that could be the cause of the problem... 请注意,该驱动程序本应以32位元构建,并且我正在尝试针对64位元构建该驱动程序,如果这可能是问题的原因,那就不知道了。

What if we also look in the xmmintrin.h header? 如果我们还查看xmmintrin.h标头,该怎么办?

/* Set the control register to I.  */
extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_setcsr (unsigned int __I)
{
  __builtin_ia32_ldmxcsr (__I);
}

Ouch, another use of __I . __I__I另一种用法。

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

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