[cfe-dev] warning: declaration does not declare anything / error: no member named 'LOW' in 'STRUCT'

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 30 11:53:36 PDT 2018


On 7/30/2018 9:08 AM, Frank Redeker via cfe-dev wrote:
> Hello List,
>
> Given the following piece of code.
>
> typedef union {
> 	struct {
> 		unsigned char	LOW;
> 		unsigned char	HIGH;
> 	};
> 	unsigned short	SHORT;		
> } UNION;
>
> typedef struct {
> 	UNION; // <-- use of type only
> 	union {
> 		unsigned char	FOO;
> 	};
> } STRUCT;
>
> STRUCT	Variable;
>
> void Function () {
> 	Variable.LOW = 1;
> }
>
>
> This code compiles without any error using gcc 7.2 (When compiling with
> -ansi -pedantic I get the warning "ISO C90 doesn't support unnamed
> structs/unions". If I add -std=c11 the warning disappears)

Declaring an anonymous union like that non-standard; you need to pass 
-fms-extensions.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the cfe-dev mailing list