compiler-warnings

Warning: passing argument from distinct Objective-C type

I am currently trying to compile OCMock with GCC4.2 (original: 4.0) and start getting the following warning: warning: passing argument 1 of 'partialMockForObject:' from distinct Objective-C type the calling method is: - (void)forwardInvocationForRealObject:(NSInvocation *)anInvocation { // in here "self" is a reference to ...

C++: Casting for user defined types

How can I get the same handeling of casting for user-defined types as built in, eg: float a = 5.4; std::string s = a;//error, no conversion avaible int x = a;//warning, possible data loss int y = (int)a;//fine int z = static_cast<int>a;//fine float b = c;//warning, possible data loss Now say I have my own Int and Float class, how do I...

Scala: comparing fresh objects

Hi, I was browsing scala tests and I don't understand why the compiler produces a warning when you compare "two fresh objects". This is the test' outputs: http://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/test/files/neg/checksensible.check Example: checksensible.scala:12: warning: comparing a fresh object using `!=' will always ...

How to get rid of C4800 warning produced by boost::flyweight in VS2008

Hi, I get a warning when compiling below code in VS2008 with MFC turned on. Boost version 1.39 include "boost/flyweight.hpp" include "boost/flyweight/key_value.hpp" class Foo { public: Foo(const CString} private: const CString mfoo; }; struct Conversion { const CString} }; using namespace boost::flyweights; flyweight<...

How can I suppress javac warnings about deprecated api?

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 ...

Java Class.cast() vs. cast operator.

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 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...

Custom Compiler Warnings in Visual Studio 2008

http://stackoverflow.com/questions/154109/custom-compiler-warnings and http://stackoverflow.com/questions/968249/c-create-custom-warning-in-visual-studio-if-certain-method-is-used-in-source-co haven't helped as they deal with code that is under the author's control. We are using a 3rd party suite of UI controls (DevExpress) in our softw...

LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification

I recently converted a multi-project solution to use .dlls instead of .libs for each of the projects. However, I now get a compiler warning for each project as stated in the example. MSDN didn't serve to be all that helpful with this. Why is this and howcan I solve it? Warning 2 warning LNK4075: ignoring '/EDITANDCONTINUE' due...

Compiler warning with nested vectors of depth 3 or more

Hi, I am trying to use a class member that uses nested vectors of depth 3: vector< vector< vector > > classVariable_; However, I then get compiler warnings throughout my code when I try do something as simple as classVariable_.clear(): /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h: In member function `std::vector<_T...

Why this warning from IBM XL C/C++ compiler?

Here's a minimum code example that illustrates the problem: #include <iostream> class Thing { // Non-copyable Thing(const Thing&); Thing& operator=(const Thing&); int n_; public: Thing(int n) : n_(n) {} int getValue() const { return n_;} }; void show(const Thing& t) { std::cout << t.getValue() << std::endl; } ...

unnecessary (?) Xcode warning

I'm running Xcode in OS X 10.6 on a Core 2 Duo. Here's a short program: #include <stdio.h> int main () { long a = 8589934592L; printf("a = %li\n", a); return 0; } When I compile this from the command line (gcc -pedantic) I get no errors or warning. When I compile this in Xcode in debug configuration, I get no errors or ...

Optional argument cannot be erased?

I wanted to have a tail-recursive version of List.map, so I wrote my own. Here it is: let rec list_map f l ?(accum=[])= match l with head :: tail -> list_map f tail ~accum:(head :: accum) | [] -> accum;; Whenever I compile this function, I get: File "main.ml", line 69, characters 29-31: Warning X: this optional argument ...

Why "not all control paths return a value" is warning and not an error?

I was trying to answer this question. As suggested by the accepted answer, the problem with that code is that not all control paths are returning a value. I tried this code on the VC9 compiler and it gave me a warning about the same. My question is why is just a warning and not an error? Also, in case the path which doesn't return a valu...

How to intentionally cause a custom java compiler warning message?

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, some...

Visual Studio: Warn when private or internal members have no references

Is there a way to get visual studio to warn that a private member does not have any references within the class? How about internal members that have no references within the package / module? I have been re-factoring my code and I don't want to keep [right-click] --> Find All References for each member in my code base to ensure I have ...

Supressing warnings for a codeblock using gcc 4.1.2?

I have a section of code that uses a Boost library that results in a lot of these type of warning messages: class x has virtual functions but non-virtual destructor Using g++ 4.1.2, how do I temporarily disable warnings for this codeblock then enable them again after it. Everything I try (pragma gcc diagnostic, etc) seems to only be ...

Why does gcc report "implicit declaration of function ‘round’"?

I have the following C code: #include <math.h> int main(int argc, char ** argv) { double mydouble = 100.0; double whatever = round(mydouble); return (int) whatever; } When I compile this, I get the warnings: round_test.c: In function ‘main’: round_test.c:6: warning: implicit declaration of function ‘round’ round_test.c:...

iPhone SDK warning: class MyAppViewController does not implement the 'UITabbarDelegate' protocol

Im working on an iPhone app, not using IB, and programmatically created a UITabbar with three items in a UIViewController in a view based application, I used one delegate method, that wont work without the last line in the snippet below( setDelegate method). I dont have a tabbarviewcontroller. UITabBar *tabbar = [[UITabBar alloc] in...

Does anyone know of a way to view all compiler warnings for a VB.NET project?

VB.NET has this rather annoying limitation which caps compiler warnings reported at 100. vbc : warning BC42206: Maximum number of warnings has been exceeded. This makes things rather frustrating when trying to size up the amount of effort that would be required to comply with VB.NET best practices, such as enabling Option Strict. Is ...

Providing suggested solutions in error messages

Developer tools and software typically do not provide solution suggestions in error messages. This makes sense for compilers because they are supposed to tell precisely what went wrong. There are "lint" tools to provide suggestions, but AFAIK, few developers use lint tools regularly or even at all. There is a large set of developer...