compiler-warnings

Java Generics, how to avoid unchecked assignment warning when using class hierarchy?

自作多情 提交于 2019-11-27 02:51:54
问题 I want to use a method using generic parameters and returning generic result on a class hierarchy. edit: no SupressWarnings("unchecked") answer allowed :-) Here is a sample code illustrating my problem: import java.util.*; public class GenericQuestion { interface Function<F, R> {R apply(F data);} static class Fruit {int id; String name; Fruit(int id, String name) { this.id = id; this.name = name;} } static class Apple extends Fruit { Apple(int id, String type) { super(id, type); } } static

C# Compiler Warning 1685

蹲街弑〆低调 提交于 2019-11-27 02:29:24
问题 So, (seemingly) out of the blue, my project starts getting compiler warning 1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll' Perplexed, I researched the MSDN article to figure out its cause. Here's the information I found: Visual C# Reference: Errors and Warnings Compiler Warning (level 1) CS1685 Error

GCC does not honor 'pragma GCC diagnostic' to silence warnings [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-27 02:05:42
问题 This question already has an answer here: Suppress -Wunknown-pragmas warning in GCC 1 answer We recently enabled -Wall for a project. Its enabled when GCC is at 4.7 or above (or Clang) because we can use GCC diagnostic to manage the output from the elevated warnings. We want to manage them from the source code, and not via command line arguments. (We don't want to pollute the command line, or ask library users to rediscover what is needed). Under GCC 4.8 and 5.1, we are catching warnings that

Boolean expression order of evaluation in Java?

北城余情 提交于 2019-11-27 02:04:33
问题 Suppose I have the following expression String myString = getStringFromSomeExternalSource(); if (myString != null && myString.trim().length() != 0) { ... } Eclipse warns me that myString might be null in the second phrase of the boolean expression. However, I know some that some compilers will exit the boolean expression entirely if the first condition fails. Is this true with Java? Or is the order of evaluation not guaranteed? 回答1: However, I know some that some compilers will exit the

PerformSelector warning

主宰稳场 提交于 2019-11-27 01:57:39
问题 I'm receiving a warning PerformSelector may cause a leak because its selector is unknown In the code: - (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err { assert([NSThread isMainThread]); if([delegate respondsToSelector: selector]) { if(arg != NULL) { //this line the warning [delegate performSelector: selector withObject: arg withObject: err]; } else { //this line the warning [delegate performSelector: selector withObject: err]; } } else { NSLog(@"Missed Method"); }

How to use clang++ with -std=c++11 -Weverything -Werror

眉间皱痕 提交于 2019-11-27 01:57:28
问题 I want to compile the following file (temp.cpp): #include <iostream> class Foo { public: Foo() = default; }; int main(){ std::cout << "Works!" << std::endl; return 0; } With the following command: clang++ temp.cpp -o temp -std=c++11 -Weverything -Werror There is an error: temp.cpp:5:11: error: defaulted function definitions are incompatible with C++98 [-Werror,-Wc++98-compat] I understand that there is a warning like c++98-compat and it is part of everything. How can I enable all warnings

Universally compiler independent way of implementing an UNUSED macro in C/C++

拥有回忆 提交于 2019-11-27 01:52:56
问题 When implementing stubs etc. you want to avoid "unused variable" warnings. I've come across a few alternatives of UNUSED() macros over the years, but never one which either is proven to work for "all" compilers, or one which by standard is air tight. Or are we stuck with #ifdef blocks for each build platform? EDIT: Due to a number of answers with non c-compliant alternatives, I'd like to clarify that I'm looking for a definition which is valid for both C and C++, all flavours etc. 回答1:

How can I suppress javac warnings about deprecated api?

佐手、 提交于 2019-11-27 01:44:31
问题 When I compile, javac outputs: Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.` I wish to suppress this warning. Trying -Xlint:none does not seem to help. 回答1: From what I can tell in the docs, you can't do it on the command-line. According to the javac documentation, -Xlint:none only disables warnings "not mandated by the Java Language Specification". It appears that warning you of the use of deprecated APIs is managed by the

Visual Studio warning level meanings?

孤人 提交于 2019-11-27 01:43:18
问题 On the build tab in a Web Application project I have a setting called "Warning Level". I can set a value from 0 to 4. What do these values mean? Will a value of 0 be more strict and generate more warnings, or vice versa? I haven't been able to find any documentation on it yet, but perhaps I'm looking in the wrong place. 回答1: This link shows you the definitions of the warning levels (I'm assuming you are using C# code in your web project). Level 4 is the most strict. 0: Turns off emission of

disable specific warnings in gcc

混江龙づ霸主 提交于 2019-11-27 01:31:31
On microsoft compilers, specific warnings can be disabled with a #pragma, without disabling other warnings. This is an extremely useful feature if the compiler warns over something that "has to be done". Does GCC at this point have a similar feature? It seems like an obvious enough feature that its unimaginable that it wouldn't have this feature yet, but older info on the web suggests this feature doesn't exist. What is one to use in GCC? Specifically, I like to use multi-character constants, like 'abc'. These evaluate effectively as a base 256 number - a very handy feature, but it triggers a