- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I added -Wextra to my build to make the code cleaner. But I get an "Empty body in an else statement" warning which -Wextra does enable (see: http://gcc.gnu.org/onlinedocs/gcc/warning-options.html#warning-options).
So I added -Wno-empty-body to the NIOS II compiler warnings text line and I get this error: cc1.exe: error: unrecognized command line option "-Wno-empty-body". I also get the error using -Wempty-body. So the question is, what is the right option for this warning? Thanks, Bill링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Check the documentation for the version of gcc you are using, -Wempty-body is probably a very new option.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I thought that might be the case. I know the NIOS II GCC compiler (4.x?) is behind the latest GCC release. So does this mean the NIOS II GCC compiler generates the warning without any way to disable it?
Thanks dsl! Bill- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
A quick look in the gcc sources (having repoduced the error message with a random gcc 4.1.2 since you misquoted it) shows it being generated in c_finish_if_stmt() in c-typeck.c.
The code is inside 'if (extra_warnings)' - probably set by -Wextra, and is: warning (0, "%Hempty body in an else-statement",
EXPR_LOCUS (*inner_else));
Compare this against, a few lines higher: warning (OPT_Wparentheses,
"%Hsuggest explicit braces to avoid ambiguous %<else%>",
&if_locus);
My guess is that the first argument to warning() maps onto the flag to enable/disable the warning. So you are probably out of luck.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Wow, thanks for the research! Much appreciated. I think you're right - the 0 argument is telling. I guess the next step is to explicitly call out the -W options excluding empty_body that -Wextra turns on. Like:
-Wclobbered
-Wignored-qualifiers
-Wmissing-field-initializers
-Wmissing-parameter-type
-Wold-style-declaration
-Woverride-init
-Wsign-compare
-Wtype-limits
-Wuninitialized
-Wunused-parameter
-Wunused-but-set-parameter
I tried the above options. LOL - 7 of these aren't recognized! Oh well. Thanks again, Bill
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
There is an option to the compiler to list the known -W (etc) options.
The gcc docs web site does have info for (some) older versions.- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
missing-field-initialisers and unused-parameter are somewhat horrid, fixing 'sign-compare' is bad enough
