compiler-warnings

Suppressing Class Method Not Found Warnings in Xcode [duplicate]

前提是你 提交于 2019-12-07 02:18:07
问题 This question already has answers here : Using #pragma to suppress “Instance method not found” warnings in Xcode (5 answers) Closed 5 years ago . I have a class whose methods are determined at runtime, as indicated in my question here. This works great, but now I have a bunch of warnings that look like the following littering my code: Class method '+objectIsNotNil:' not found (return type defaults to 'id') While these warnings don't actually affect the build process, they're very annoying and

How to enable all compiler warnings in CLion?

时光毁灭记忆、已成空白 提交于 2019-12-07 01:00:49
问题 I want to see all compiler warnings in CLion. I don't want them treated as errors, but I want to inspect all of them. How can I do this? 回答1: Try to set compiler flag in CMakeLists.txt : set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") Related question: How to enable C++11 in CLion? 回答2: For C: set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 回答3: Rebuild your entire project. Most compilers don't rebuild every file when you just press build, so you will only see warnings from

warning C4172: returning address of local variable or temporary [duplicate]

为君一笑 提交于 2019-12-06 16:44:05
This question already has answers here : Closed 7 years ago . Possible Duplicate: Pointer to local variable I've read a lot of other topics on this site about the same problem knowing it would be common. But I guess I'm dumb and can't figure out the proper way to do it. So, I apologize for yet another one of these questions and I'm hoping someone can give me a simple solution and/or explanation. Here's the entire code: Main.c #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <stdlib.h> #include <tchar.h> LPTSTR GetApplicationPath ( HINSTANCE Instance ); int APIENTRY _tWinMain (

“value returned is unused” warning when byte-compiling a macro

本小妞迷上赌 提交于 2019-12-06 13:54:36
Why does byte-compiling the the following produce a warning? (defmacro foomacro (shiftcode) `(defun foo (&optional arg) (interactive ,(concat shiftcode "p")) (message "arg is %i" arg)) `(defun bar (&optional arg) (interactive ,(concat shiftcode "Nenter a number: ")) (message "arg is %i" arg))) ;; provide backward compatibility for Emacs 22 (if (fboundp 'handle-shift-selection) (foomacro "^") (foomacro "")) This is the warning I get: $ emacs -Q --batch --eval '(byte-compile-file "foo.el")' In foomacro: foo.el:1:21:Warning: value returned from (concat shiftcode "p") is unused If I get rid of bar

warning: assignment from incompatible pointer type for linklist array

丶灬走出姿态 提交于 2019-12-06 11:59:29
I am executing a C program where I am getting warning: warning: assignment from incompatible pointer type I am copying related code herein: //Structure I am using: typedef struct graph_node { int id; int weight; struct node *next; }node, dummy; node *head[10]; // Function which is generating this warning: void print_list() { int i; for (i = 0;i< vertex; i++) { printf ("\n ==>>%d ", head[i]->id); while (head[i]->next != NULL) { head[i] = head[i]->next; printf ("\t ==>>%d ", head[i]->id); /******This line is generating warning ********/ } } } Above code compiles fine with throws the warning

Java eclipse highlight missing brackets

强颜欢笑 提交于 2019-12-06 09:26:48
I just can't find the option anywhere. Is there some way in eclipse to warn about stuff like this? if(a==b)continue; instead of if(a==b){continue;} Or can maybe the format function fix this? CheckStyle is a nice tool which can also be used as a plugin for eclipse. You can specify different kinds of coding styles you want to enforce on you / your team, by configuring rules in this tool. This could help you create your custom check. Window-->Preferences--> Java > Editor > Save Actions-->Additional actions-->Configure-->Code Style--> Use blocks in if/while... here you can configure the style you

how to make g++ generate an error/warning for int i = i?

大城市里の小女人 提交于 2019-12-06 08:09:01
I had a hard time to find a bug in my code caused by a loop like this: for (int i=i;i<5;i++){ // ... } I use g++ 4.7.2 with -O2 -Wall , but no warning/error is shown. Is there some compiler flag that also in combination with -O2 creates a warning for such a case? I found several related questions: here in the comments it is discussed, that g++ shows a warning with -Wall when there is no -O2 . However, that question is particular because the problematic loop is optimized away with -O2 which would explain that no warning is shown. In my case the loop is not optimized away, but still I get no

How to enable warnings for incorrect use of TRACE / ATLTRACE

懵懂的女人 提交于 2019-12-06 07:05:41
问题 The following MFC program (taken from this question) has obvious errors as the format specifiers do not match the actual argument types: #include <afx.h> int main() { int const a = 0; ULONGLONG const len = 1000; ULONGLONG const pos = 800; double const perc = static_cast<double>( pos ) / static_cast<double>( len * 100 ); TRACE( "load from %X, Position: %ld, Length: %ld, Perc: %lf \n", &a, pos, len, perc ); } Yet, there are no compiler warnings. I have build this in debug configuration with

Failing compilation if return value is unused for a certain type

我怕爱的太早我们不能终老 提交于 2019-12-06 05:48:27
问题 I would like to make compilation fail for some function call but not others. The function call that I want to fail are those that do not handle return values when the value is of a certain type. In the example below, not handling a function returning Error is a compilation error but not handling a function that returns anything else should succeed just fine. Note: our runtime environment (embedded) does not allow us to use the following constructs: RTTI, exceptions. This code only needs to

Intel C++ Compiler warning 167 when non-const argument is passed as const parameter [duplicate]

感情迁移 提交于 2019-12-06 04:48:45
问题 This question already has answers here : Why isn't it legal to convert “pointer to pointer to non-const” to a “pointer to pointer to const” (5 answers) Closed 6 years ago . I have a large codebase that recently moved from Microsoft's compiler to the Intel C++ Compiler. Our team's goal is compilation without warnings in the mainline. Since the switch, one instance of warning 167 has confounded me. If I compile the following code: int foo(const int pp_stuff[2][2]) { return 0; } int foo2(const