compiler-warnings

java: how to use clone() and what about the cast check

情到浓时终转凉″ 提交于 2019-12-17 20:37:44
问题 This code: class RawStringIterator { java.util.Stack<State> stateStack = new java.util.Stack<State>(); RawStringIterator(RawStringIterator i) { stateStack = (java.util.Stack<State>) i.stateStack.clone(); } /* ... */ } gives me this warning: Type safety: Unchecked cast from Object to Stack<Utils.OperatorTree.RawStringIterator.State> I guess I can ignore the warning here. But I wonder about how to use clone() in general? Do I always have to use a @SuppressWarnings("unchecked") every time I use

How to detect unused methods and #import in Objective-C

安稳与你 提交于 2019-12-17 17:26:28
问题 After working a long time on an iPhone app, I realized that my code is quite dirty, containing several #import and methods that are not called or useful at all. I would like to know if there's any compiler directive or way to detect those useless lines of code. Does Xcode have any tool to detect this? 回答1: Xcode allows you to (un)check settings for specific compiler warnings that can warn you of some types of unused code. (Select the project in the source list and File > Get Info, then select

Is there a way to suppress warnings in C# similar to Java's @SuppressWarnings annotation?

天涯浪子 提交于 2019-12-17 16:31:49
问题 Is there a way to suppress warnings in C# similar to Java's @SuppressWarnings annotation? Failing that, is there another way to suppress warnings in Visual Studio? 回答1: Yes. For disabling, use : #pragma warning disable 0169, 0414, anyothernumber Where the numbers are the identifiers of the warnings that you can read from compiler output. To reenable the warnings after a particular part of code (which is a good idea) use: #pragma warning restore 0169, anythingelse This way you can make the

How to eliminate warning about ambiguity?

孤街醉人 提交于 2019-12-17 16:24:14
问题 I have this warning: Warning 3 Ambiguity between method 'Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. Using method group. on my line wordApplication.Quit(); I have tried replacing it with: wordApplication.Quit(false); // don't save changes and wordApplication.Quit(false, null, null); // no save, no format but it keeps giving me this warning. It's not a huge problem because the

C/C++: How to use the do-while(0); construct without compiler warnings like C4127?

▼魔方 西西 提交于 2019-12-17 15:34:57
问题 I'm often use do-while(0) construct in my #defines, for the reasons described in this answer. Also I'm trying to use as high as possible warning level from compiler to catch more potential problem and make my code more robust and cross-platform. So I'm typically using -Wall with gcc and /Wall with MSVC. Unfortunately MSVC complain about do-while(0) construct: foo.c(36) : warning C4127: conditional expression is constant What should I do about this warning? Just disable it globally for all

What's the point of g++ -Wreorder?

雨燕双飞 提交于 2019-12-17 15:10:01
问题 The g++ -Wall option includes -Wreorder. What this option does is described below. It is not obvious to me why somebody would care (especially enough to turn this on by default in -Wall). -Wreorder (C++ only) Warn when the order of member initializers given in the code does not match the order in which they must be executed. For instance: struct A { int i; int j; A(): j (0), i (1) { } }; The compiler will rearrange the member initializers for i and j to match the declaration order of the

Ignore all warnings in a specific file using LLVM/Clang

谁都会走 提交于 2019-12-17 10:12:44
问题 There are some files in my iOS project that have some warnings, and I want to ignore those warnings. I don't want to disable warnings in the entire project (know how to do that), just some specific files. So, is there a way to completely ignore all warnings from a specific file? I'm using LLVM 3.0 and Clang on Xcode 4.2. 回答1: if you're just using clang, then you should use the pragma syntax for sources you maintain (assuming it is impossible to remove the warning by altering the program

How can I disable compiler warnings in Eclipse on a file specific basis? [duplicate]

送分小仙女□ 提交于 2019-12-17 09:43:40
问题 This question already has answers here : Change Eclipse settings to ignore errors on a specific file (7 answers) Closed 5 months ago . In my Eclipse project are a handful of generated .java files that I need to use for SQLJ and I can't move to a separate project (due to Administrative Overhead). These files are also regularly regenerated so editing them is unfortunately out. Unfortunately these files generate a few hundred java compiler warnings which drown out the useful warnings I get on

Is it wise to ignore gcc/clang's “-Wmissing-braces” warning?

社会主义新天地 提交于 2019-12-17 09:38:11
问题 Consider the following program: #include <array> int main() { std::array<int, 1> x = { 0 }; // warning! x = { { 0 } }; // no warning return 0; } The first initialization leads to warnings on gcc 4.7.2... main.cpp:5:22: warning: unused variable ‘x’ [-Wunused-variable] ... and clang 3.1 main.cpp:5:28: warning: suggest braces around initialization of subobject [-Wmissing-braces] std::array<int, 1> x = { 0 }; As far as the standard goes, there should be no difference between double or single

How do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit?

旧巷老猫 提交于 2019-12-17 08:10:18
问题 I'd like to know what switch you pass to the gcc compiler to turn off unused variable warnings? I'm getting errors out of boost on windows and I do not want to touch the boost code: C:\boost_1_52_0/boost/system/error_code.hpp: At global scope: C:\boost_1_52_0/boost/system/error_code.hpp:214:36: error: 'boost::system::posix_category' defined but not used [-Werror=unused-variable] C:\boost_1_52_0/boost/system/error_code.hpp:215:36: error: 'boost::system::errno_ecat' defined but not used [