compiler-warnings

Selectively disable GCC warnings for only part of a translation unit?

爷,独闯天下 提交于 2019-11-26 00:47:52
问题 What\'s the closest GCC equivalent to this MSVC preprocessor code? #pragma warning( push ) // Save the current warning state. #pragma warning( disable : 4723 ) // C4723: potential divide by 0 // Code which would generate warning 4723. #pragma warning( pop ) // Restore warnings to previous state. We have code in commonly included headers which we do not want to generate a specific warning. However we want files which include those headers to continue to generate that warning (if the project

How to disable GCC warnings for a few lines of code

雨燕双飞 提交于 2019-11-26 00:15:35
问题 In Visual C++, it\'s possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for \"next line\", or with push/pop semantics around areas of code using GCC? 回答1: It appears this can be done. I'm unable to determine the version of GCC that it was added, but it was sometime before June 2010. Here's an example: #pragma GCC diagnostic error "-Wuninitialized" foo(a); /* error is given for this one */ #pragma GCC diagnostic

warning: implicit declaration of function

此生再无相见时 提交于 2019-11-25 22:48:40
问题 My compiler (GCC) is giving me the warning: warning: implicit declaration of function Please help me understand why is it coming. 回答1: You are using a function for which the compiler has not seen a declaration (" prototype ") yet. For example: int main() { fun(2, "21"); /* The compiler has not seen the declaration. */ return 0; } int fun(int x, char *p) { /* ... */ } You need to declare your function before main, like this, either directly or in a header: int fun(int x, char *p); 回答2: The