解决keil_mdk编译error: #3092: anonymous unions are only supported in --gnu mode

转自 https://blog.csdn.net/weixin_42108004/article/details/83024170

error:  #3092: anonymous unions are only supported in --gnu mode, or when enabled with #pragma anon_unions

错误:匿名联合仅在--gnu模式下支持,或者在使用#pragma anon_unions时启用

解决方法1:

在arm编译器中会定义 __CC_ARM ,其功能是启用对匿名结构和联合的支持

添加代码:

    #if defined ( __CC_ARM   )
    #pragma anon_unions
    #endif

或者直接添加:

#pragma anon_unions

解决方法2:

在union后加一个定义的变量

 union {
                        __IO uint16_t InfAll;
                        struct {
                            __IO uint16_t FramLength : 15;
                            __IO uint16_t FramFinishFlag : 1;
                        
                        }InfBit;            
        }Info;    


 

猜你喜欢

转载自blog.csdn.net/wofreeo/article/details/89314250