compiler-warnings

How to intentionally cause a custom java compiler warning message?

本秂侑毒 提交于 2019-11-26 05:55:40
问题 I\'m about to commit an ugly temporary hack in order to work around a blocking issue while we wait for an external resource to be fixed. Aside from marking it with a big scary comment and a bunch of FIXMEs, I\'d love to have the compiler throw an obvious warning message as a reminder so we don\'t forget to take this out. For example, something like: [javac] com.foo.Hacky.java:192: warning: FIXME temporary hack to work around library bug, remove me when library is fixed! Is there a way I can

What is the list of valid @SuppressWarnings warning names in Java?

浪子不回头ぞ 提交于 2019-11-26 05:34:41
What is the list of valid @SuppressWarnings warning names in Java? The bit that comes in between the ("") in @SuppressWarnings("") . cletus It depends on your IDE or compiler. Here is a list for Eclipse Galileo: all to suppress all warnings boxing to suppress warnings relative to boxing/unboxing operations cast to suppress warnings relative to cast operations dep-ann to suppress warnings relative to deprecated annotation deprecation to suppress warnings relative to deprecation fallthrough to suppress warnings relative to missing breaks in switch statements finally to suppress warnings relative

Does there exist a static_warning?

浪尽此生 提交于 2019-11-26 05:22:10
问题 I\'m aware of this question which mentions Boost\'s \"STATIC WARNING\", but I\'d like to ask again, specifically, how I could implement a static_warning which operates similarly to static_assert but only emits a warning at compile time rather than an aborting compilation error. I\'d like something similar to Alexandrescu\'s proposal for a static assert in pre-C++11 days which somehow managed to print some useful contextual information as part of the error. It would be acceptable to require

How to disable unused code warnings in Rust?

邮差的信 提交于 2019-11-26 05:22:08
问题 struct SemanticDirection; fn main() {} warning: struct is never used: `SemanticDirection` --> src/main.rs:1:1 | 1 | struct SemanticDirection; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(dead_code)] on by default I will turn these warnings back on for anything serious, but I am just tinkering with the language and this is driving me bats. I tried adding #[allow(dead_code)] to my code, but that did not work. 回答1: You can either: Add an allow attribute on a struct, module, function, etc.: #

Java Class.cast() vs. cast operator

拈花ヽ惹草 提交于 2019-11-26 04:08:19
问题 Having being taught during my C++ days about evils of the C-style cast operator I was pleased at first to find that in Java 5 java.lang.Class had acquired a cast method. I thought that finally we have an OO way of dealing with casting. Turns out Class.cast is not the same as static_cast in C++. It is more like reinterpret_cast . It will not generate a compilation error where it is expected and instead will defer to runtime. Here is a simple test case to demonstrate different behaviors.

How to turn on (literally) ALL of GCC's warnings?

陌路散爱 提交于 2019-11-26 04:06:45
问题 I would like to enable -- literally -- ALL of the warnings that GCC has. (You\'d think it would be easy...) You\'d think -Wall might do the trick, but nope! Still need -Wextra . You\'d think -Wextra might do the trick, but nope! Not all of the warnings listed here (for example, -Wshadow ) are enabled by this. And I still have no idea if this list is comprehensive. How do I tell GCC to enable (no if\'s, and\'s, or but\'s!) all the warnings it has? 回答1: You can't. The manual for GCC 4.4.0 is

What are the valid characters for macro names?

可紊 提交于 2019-11-26 02:23:44
问题 Are C-style macro names subject to the same naming rules as identifiers? After a compiler upgrade, it is now emitting this warning for a legacy application: warning #3649-D: white space is required between the macro name \"CHAR_\" and its replacement text #define CHAR_& 38 This line of code is defining an ASCII value constant for an ampersand. #define DOL_SN 36 #define PERCENT 37 #define CHAR_& 38 #define RT_SING 39 #define LF_PAR 40 I assume that this definition (not actually referenced by

What is the list of valid @SuppressWarnings warning names in Java?

心已入冬 提交于 2019-11-26 01:55:29
问题 What is the list of valid @SuppressWarnings warning names in Java? The bit that comes in between the (\"\") in @SuppressWarnings(\"\") . 回答1: It depends on your IDE or compiler. Here is a list for Eclipse Galileo: all to suppress all warnings boxing to suppress warnings relative to boxing/unboxing operations cast to suppress warnings relative to cast operations dep-ann to suppress warnings relative to deprecated annotation deprecation to suppress warnings relative to deprecation fallthrough

Custom Compiler Warnings

不想你离开。 提交于 2019-11-26 01:36:33
问题 When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I\'m currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods or properties that will generate compiler warnings that give messages that I write. Something like this [MyAttribute(\"This code sux and should be looked at\")] public void

Multi-character constant warnings

谁说我不能喝 提交于 2019-11-26 01:26:32
问题 Why is this a warning? I think there are many cases when is more clear to use multi-char int constants instead of \"no meaning\" numbers or instead of defining const variables with same value. When parsing wave/tiff/other file types is more clear to compare the read values with some \'EVAW\', \'data\', etc instead of their corresponding values. Sample code: int waveHeader = \'EVAW\'; Why does this give a warning? 回答1: According to the standard (§6.4.4.4/10) The value of an integer character