compiler-warnings

How can I get the compiler to warn me of unused code that is marked pub?

匆匆过客 提交于 2020-08-27 08:29:48
问题 Rust warns for unused private items: warning: function is never used: `hmm` --> src/example.rs:357:1 | 357 | fn hmm() { | ^^^^^^^^ | = note: #[warn(dead_code)] on by default I have some code marked pub that I know is not being used. How can I get the compiler to warn me of this? This is in the context of a library and a series of binaries, all in the same workspace. The library is only used by those binaries; the library isn't being consumed by anybody else and I'm not going to upload to

Why gcc warns about narrowing conversion only for uniform initialization?

血红的双手。 提交于 2020-08-15 05:42:08
问题 I am trying to convert long type variable to int type variable with uniform initialization and without it. But I get compiler warning only with uniform initialization. Why is that? Why does not gcc warn in both cases? I have tried with clang also and got similar results. This is the code #include <iostream> int main() { long l = 1; int i1 = l; int i2 = { l }; std::cout << i1 << std::endl; std::cout << i2 << std::endl; return 0; } And the only one warning I get $ g++ -Wall -Wextra 1.cpp 1.cpp:

Why gcc warns about narrowing conversion only for uniform initialization?

烂漫一生 提交于 2020-08-15 05:42:08
问题 I am trying to convert long type variable to int type variable with uniform initialization and without it. But I get compiler warning only with uniform initialization. Why is that? Why does not gcc warn in both cases? I have tried with clang also and got similar results. This is the code #include <iostream> int main() { long l = 1; int i1 = l; int i2 = { l }; std::cout << i1 << std::endl; std::cout << i2 << std::endl; return 0; } And the only one warning I get $ g++ -Wall -Wextra 1.cpp 1.cpp:

Treating warnings as errors in Visual Studio 2019 for build but NOT intellisense

依然范特西╮ 提交于 2020-07-23 06:16:20
问题 I've just started using <TreatWarningsAsErrors>true</TreatWarningsAsErrors> in my csproj files, and when messing up a bit of code, I've found myself taking quite a bit of extra time hovering over all the different red lines to find the one that's actually an error, as I want to prioritse fixing the errors over the warnings. It would be great if the intellisense warnings could still show as green lines in the text editor, but also cause the build to fail. I think that I could make the test

Treating warnings as errors in Visual Studio 2019 for build but NOT intellisense

心不动则不痛 提交于 2020-07-23 06:15:41
问题 I've just started using <TreatWarningsAsErrors>true</TreatWarningsAsErrors> in my csproj files, and when messing up a bit of code, I've found myself taking quite a bit of extra time hovering over all the different red lines to find the one that's actually an error, as I want to prioritse fixing the errors over the warnings. It would be great if the intellisense warnings could still show as green lines in the text editor, but also cause the build to fail. I think that I could make the test

Treating warnings as errors in Visual Studio 2019 for build but NOT intellisense

僤鯓⒐⒋嵵緔 提交于 2020-07-23 06:14:11
问题 I've just started using <TreatWarningsAsErrors>true</TreatWarningsAsErrors> in my csproj files, and when messing up a bit of code, I've found myself taking quite a bit of extra time hovering over all the different red lines to find the one that's actually an error, as I want to prioritse fixing the errors over the warnings. It would be great if the intellisense warnings could still show as green lines in the text editor, but also cause the build to fail. I think that I could make the test

Dart 2.8.0 sdk: how to globally ignore omit_local_variable_types warning?

泄露秘密 提交于 2020-07-09 07:24:50
问题 I'm developing a mobile app plus web frontend with Dart / Flutter with IntelliJ Idea. The current version of Dart (2.8.0) warns about correctly typing local variables. There is a Dart style guide https://dart-lang.github.io/linter/lints/omit_local_variable_types.html saying "Usually, the types of local variables can be easily inferred, so it isn't necessary to annotate them." This might be true for a compiler but it sure is not true for human readers. Since it especially defers type problems

How can I display a compiler warning upon function invocation?

蓝咒 提交于 2020-06-27 14:46:08
问题 I've got a function I want to export in my module so people can use it. However, in ≈95% of cases, using it is a bad idea. /// Check whether foo is a metasyntactic variable. /// /// **Using this function is a mistake.** This function is slow, /// since checking widgets is an extremely expensive operation. /// You should be keeping track of what's what, and ideally will /// never need to use this function. /// /// If you _do_ need to use this function, please consider a refactor. pub fn test

How to avoid deprecation warnings when @SuppressWarnings(“deprecation”) doesn't work?

邮差的信 提交于 2020-06-10 02:21:31
问题 We have a Java project. We enable -Xlint (enable warnings) and -Werror (treat warning as error) flags for javac , to make sure our code is warning-free. Recently we decide to deprecate a class. The problem is in some cases @SuppressWarnings("deprecation") will not suppress the deprecation warning at all, resulting in build failure. Below is a list of use cases that I ran into: Imported in other non-deprecated classes. Imported in other deprecated classes. Parent class. Type parameter. For

How to make OCaml compiler report unused functions?

走远了吗. 提交于 2020-05-30 04:26:20
问题 I wonder if is there any ways to make OCaml compiler report warnings about unused functions ? I googled but there are not much topics discussed about this feature. In particular, in the following program, there are two functions "foo" and "bar" which are declared but "bar" is not used in the "_" function. So I think that the OCaml compiler should report "bar" as an unused function. let foo x y = x + y let bar x y z = x + y + z (* should be reported unused *) let _ = let x = foo 1 2 in x 回答1: