Error: anonymous structs are a Microsoft extension [-Werror,-Wmicrosoft-anon-tag]

Hi,

i am compiling user space c code (multiple C files) using ‘clang’ compiler and observed below error . The flag ‘-fms-extensions’ is passed to clang to avoid below error but still it’s observed.
{{
…/…/include/cmf_sys.h:1714:3: error: anonymous structs are a Microsoft extension [-Werror,-Wmicrosoft-anon-tag]
struct __cmf_sys_wccp_router;
^
…/…/include/cmf_sys.h:1715:3: error: anonymous structs are a Microsoft extension [-Werror,-Wmicrosoft-anon-tag]
struct __cmf_sys_wccp_cache;
^
2 errors generated.
}}
Request to provide input to fix above issue?

Regards
Koti

You should pass -Wno-microsoft-anon-tag to the compiler; enabling the extensions doesn’t remove warnings about using the extension, it allows use of the extension in the first place (if you don’t pass -fms-extensions, the code would fail to compile). Enabling the warning helps users to know when they’re making use of a non-portable construct. (It could perhaps be argued that enabling the extension should disable the warning unless in -pedantic mode, but we should probably make a pass over all the extension diagnostics to ensure consistent behavior there.)

Dear Aaron Ballman,

In addition to passing of ‘-Wno-microsoft-anon-tag’ , i removed -fms-extensions flag
to continue compilation of c file code mentioned in my first comment. But Immediately
i noticed below build error
{{
es -Wno-tautological-compare -Wno-sizeof-pointer-memaccess -Wno-address-of-packed-member -Wno-microsoft-anon-tag -Wno-missing-declarations -Wmicrosoft-anon-tag -Wno-implicit-function-declaration -ggdb -O2 -c ./protocol/hpi_scanner_core.c -o build/hpi_scanner_core.o -MD -MF build/hpi_scanner_core.d
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:2384: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:3010: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:3496: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:3772: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
}}
Any input above build error?

Regards
Koti

If you want to use Microsoft’s anonymous structures extension, you need to continue to pass -fms-extensions. It looks like other code you’re compiling also relies on (different) MS extensions.

Hi,

Yes. You are correct,little mistake from my end leads to confusion. i am able to getrid of warnings with inclusion of ‘fms-extensions’ and -wno-microsoft-anon-tag’. Currently i noticed build error updated in previous comment.
any input on it?
{{
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:2384: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:3010: note: instantiated into assembly here
./protocol/hpi_scanner_core.c:1274:2: error: invalid operand for instruction

}}

Without seeing the source code in question, it’s impossible to say. That said, those diagnostics are related to inline assembly (so they’re more a question for LLVM backend folks instead of Clang folks as that diagnostic comes from the backend). If you’re able to share the source, you might try starting a new thread in the Code Generation category to get more eyes on the question.

Dear Aaron

Thank you . will raise new thread by sharing few bits of code where error is triggered with clang build.

Regards
Koti