compiler-warnings

Generify JSONObject string keys

点点圈 提交于 2019-12-04 06:58:24
问题 I have existing code which use org.json.JSONObject 's Iterator JSONObject obj = new JSONObject(); obj.put("key1", "value1"); obj.put("key2", "value2"); Iterator keys = obj.keys(); ... With compile warning Iterator is a raw type. References to generic type Iterator<E> should be parameterized I can update to generic version: Iterator<?> keys = obj.keys(); But isn't there a way to "generify" JSONObject with String keys? I find this answer but its suggestion doesn't compiled JSONObject<String

How to suppress a specific warning in Swift

倖福魔咒の 提交于 2019-12-04 06:23:41
I have a Swift function doing something like this: func f() -> Int { switch (__WORDSIZE) { case 32: return 1 case 64: return 2 default: return 0 } } Because __WORDSIZE is a constant, the compiler always gives at least one warning in the switch body. Which lines are actually marked depends on the target I am building for (e.g. iPhone 5 vs. 6; interestingly iPhone 5 gives a warning for the 64-bit case whereas iPhone 6 gives two warnings for 32-bit and default). I found out that the Swift equivalent for #pragma is // MARK: , so I tried // MARK: clang diagnostic push // MARK: clang diagnostic

Where is this backward_warning.h #warning coming from?

江枫思渺然 提交于 2019-12-04 06:22:44
Without looking through every single source file in my XCode project, is there a way to find out which #include is triggering the following warning? #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. Clicking on the error in XCode just opens the backward_warning.h file, which is totally useless.

How to not invoke warning: type specifier missing?

我们两清 提交于 2019-12-04 03:54:37
问题 I am reading "The C programming Language" by Brian W. Kernighan and Dennis M. Ritchie. In chapter 1.2 "Variables and Arithmetic Expressions" they demonstrate a simple Fahrenheit to Celsius converter program. When I compile the program (Terminal.app, macOS Sierra), I get this warning: $ cc FtoC.c -o FtoC.o FtoC.c:5:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] main() ^ 1 warning generated. This is the C program: FtoC.c: 1 #include <stdio.h> 2 3 /* print Fahrenheit

Why does gcc report “implicit declaration of function ‘round’”?

一个人想着一个人 提交于 2019-12-04 03:34:09
I have the following C code: #include <math.h> int main(int argc, char ** argv) { double mydouble = 100.0; double whatever = round(mydouble); return (int) whatever; } When I compile this, I get the warnings: round_test.c: In function ‘main’: round_test.c:6: warning: implicit declaration of function ‘round’ round_test.c:6: warning: incompatible implicit declaration of built-in function ‘round’ I'm rusty with C, but I thought that the #include brought a declaration for round() into scope. I've checked my ANSI standard (C99 is the only copy I have) which confirms that the round() function exists

How to mark build as unstable when warning trend has arisen?

岁酱吖の 提交于 2019-12-04 03:20:49
问题 So we use Jenkins in conjunction with MS Build to build our projects. We also have a warnings plugin and a large number of warnings in our projects. I am trying to fight with these warnings. One of the steps which I would like to take is to mark build as unstable when number of warnings in the last build is greater than in the previous one. Maybe I should go even further and mark such build as a failure but I guess the mechanizm will be the same for both of marks. An example screenshot: I

Ignore/only show errors/warnings from certain directory using CMake

风格不统一 提交于 2019-12-04 02:55:56
问题 main question: Is there a configuration for cmake, to show or ignore compiler warnings/errors only from a certain directory? alternative solution: How can I toggle this in QtCreator? background / motivation : I'm working on a bigger CMake-project and want to focus on warnings and errors only from my subproject. I'm working with QtCreator and it annoys me to look for "my" errors/warnings under a pile of foreign ones. 回答1: You can set compiler warning options in CMake at least for certain

VS2010 (older) installer project - two or more objects have the same target location

狂风中的少年 提交于 2019-12-04 01:03:33
问题 This installer project was created back in 2004 and upgraded ever since. There are two offending dll files, which produce a total of 4 errors. I have searched online for this warning message and did not find a permanent fix (I did manage to make it go away once until I have done something like a clean, or built in Release, and then in Debug). I also tried cleaning, and then refreshing the dependencies. The duplicated entries are still in there. I also did not find a good explanation for what

Have compiler check the number of array initializers

隐身守侯 提交于 2019-12-04 00:49:55
Initializing an array (in C++, but any solution which works for C will likely work here as well) with less initializers than it has elements is perfectly legal: int array[10] = { 1, 2, 3 }; However, this can be a source of obscure bugs. Is there a way to have the compiler (gcc) check the number of initializers for one specific array, and emit a warning or even an error if declared and actual size don't match? I know I can use int array[] = { 1, 2, 3 }; and could then use static assertions involving sizeof(array) to verify my expectation there. But I'm using array in other translation units, so

Strange “Resource leak: stream is never closed” with try-with-resources if Exception is thrown in a loop

天大地大妈咪最大 提交于 2019-12-03 23:33:50
Why is Eclipse giving a strange "Resource leak: zin is never closed" warning for the following code even though I use try-with-resources : Path file = Paths.get("file.zip"); // Resource leak warning! try (ZipInputStream zin = new ZipInputStream(Files.newInputStream(file))) { for (int i = 0; i < 5; i++) if (Math.random() < 0.5) throw new Exception(); } catch (Exception e) { e.printStackTrace(); } If I modify "anything" on the code, the warning goes away. Below I list 3 modified versions which are all OK (no warnings). Mod #1: If I remove the for loop from the try block, the warning goes away: /