Questions tagged [compiler-warnings]

Messages emitted by a compiler which indicate potential problems in code or configuration.

Compiler warnings typically flag patterns in code that could potentially cause problems, but for lack of context the compiler cannot declare absolutely that the code is flawed.

2652 questions
56
votes
8 answers

Checking the gcc version in a Makefile?

I would like to use some gcc warning switchs that aren't available in older gcc versions (eg. -Wtype-limits). Is there an easy way to check the gcc version and only add those extra options if a recent gcc is used ?
Gene Vincent
  • 5,237
  • 9
  • 50
  • 86
55
votes
6 answers

Why is there a performance warning on casting pointer to bool?

This question extends Why use !! when converting int to bool?. I thought I was being cool when I did something like: bool hasParent() { return this->parentNode; } Where this->parentNode is NULL when there is no parent node. But I'm…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
55
votes
4 answers

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

Consider the following program: #include int main() { std::array 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…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
54
votes
4 answers

How to eliminate warning about ambiguity?

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…
53
votes
1 answer

How to get Intellij Idea to display compilation warnings?

I'm working with Intellij Idea 10 and Java 6 JDK Update 7. When I run Build --> Rebuild Project command, and the (javac) compilation generates warnings, Idea doesn't display what those warnings exactly are in the Messages view. I just see an…
Tommi
  • 8,550
  • 5
  • 32
  • 51
51
votes
4 answers

What are the valid characters for macro names?

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…
An̲̳̳drew
  • 13,375
  • 13
  • 47
  • 46
49
votes
3 answers

Suppress "discarded non-Unit value" warning

I have added the scalac command line argument -Ywarn-value-discard to my build because this would have caught a subtle bug that I just found in my code. However, I now get some warnings for "discarded non-Unit value" that are about intentional…
Robin Green
  • 32,079
  • 16
  • 104
  • 187
48
votes
7 answers

C# Compiler Warning 1685

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…
Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
47
votes
8 answers

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

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?
Nosrama
  • 14,530
  • 13
  • 49
  • 58
46
votes
6 answers

C++ Boost: what's the cause of this warning?

I have a simple C++ with Boost like this: #include int main() { std::string latlonStr = "hello,ergr()()rg(rg)"; boost::find_format_all(latlonStr,boost::token_finder(boost::is_any_of("(,)")),boost::const_formatter("…
sivabudh
  • 31,807
  • 63
  • 162
  • 228
45
votes
4 answers

warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++

I have the following warnings while compiling an openFrameworks 007 project on Visual Studio 2010 SP1: d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(127): warning C4003: not enough actual parameters for macro…
petersaints
  • 1,899
  • 3
  • 18
  • 25
45
votes
2 answers

Dynamic forwarding: suppress Incomplete Implementation warning

I have a class exposing some methods, whose implementation is provided by an inner object. I'm using forward invocation to dispatch at runtime the method calls to the inner object, but XCode is complaining since it cannot find an implementation of…
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
44
votes
21 answers

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

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…
bialix
  • 20,053
  • 8
  • 46
  • 63
42
votes
5 answers

error C2220: warning treated as error - no 'object' file generated

I have below class class Cdata12Mnt { public: char IOBname[ID1_IOB_PIOTSUP-ID1_IOB_TOP][BOADNAM_MAX + 4]; char ExIOBname[ID1_MAX_INF-ID1_EXIOB_U1TOP][BOADNAM_MAX + 4]; char cflpath[256]; char basetext[256]; UINT…
TrungLuu
  • 595
  • 3
  • 8
  • 9
41
votes
3 answers

Warning From Explicitly Implementing an Interface with Optional Parameters

I was playing with optional parameters to see how they would work with interfaces and I came across a strange warning. The setup I had was the following code: public interface ITestInterface { void TestOptional(int a = 5, int b = 10, object…
Craig Suchanec
  • 10,474
  • 3
  • 31
  • 39