compiler-warnings

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

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

C++/CLI : How to override Equal method of Object class

I am a newbie to C++/CLI and is having some problems trying to override the Equal method of the base Object class. I get the following compilation warning error for the following code. How should this be corrected? Warning 1 warning C4490: 'override' : incorrect use of override specifier; 'Test::Sample::Equal' does not match a base ref ...

Comparing Doubles in Visual Studio - a standard way to catch this?

Folks, Even experienced programmers write C# code like this sometimes: double x = 2.5; double y = 3; if (x + 0.5 == 3) { // this will never be executed } Basically, it's common knowledge that two doubles (or floats) can never be precisely equal to each other, because of the way the computer handles floating point arithmetic. ...

Redundant Compiler Warnings

I have found that very often, when calling myMethod asoociated with myObject1 from myObject2, I get the warning that "myObject1 may not respond to -myMethod", but then the program runs just fine anyway. Why doesn't the compiler recognize declared methods at compile time? John Doner ...

Sun Studio C++ "is not terminated with a newline" warning - how to suppress?

I have ported a fair bit of code from Win to Solaris, one of the issues I have - I am getting a heaps of warnings: Warning: Last line in file is not terminated with a newline. I like warnings - but because of the sheer amount of those I am afraid I could miss more important one. Which compiler (cc) option should I specify to silence...

Is there a way to get VS2008 to stop warning me about unreachable code?

I have a few config options in my application along the lines of const bool ExecuteThis=true; const bool ExecuteThat=false; and then code that uses it like if(ExecuteThis){ DoThis(); } if(ExecuteThat){ DoThat(); } //unreachable code warning here The thing is, we may make slightly different releases and not ExecuteThis or ExecuteTh...

Is there better way to write do-while(0) construct to avoid compiler warnings?

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

How to interpret g++ warning

Hello I've got a very strange g++ warning when tried to compile following code: #include <map> #include <set> class A { public: int x; int y; A(): x(0), y(0) {} A(int xx, int yy): x(xx), y(yy) {} bool operator< (const A &a) const { return (x < a.x || (!(a.x < x) && y < a.y)); } }; struct B { std...

'SomeViewController' may not respond to '-alloc'

I'm currently setting up this view to be swapped with another in an iPhone game. When I use this code... - (void)viewDidLoad { menuViewController = [[menuViewController alloc] initWithNibName:@"SomeViewController" bundle:nil]; self.menuViewController = menuViewController; [self.view insertSubview:menuViewController.view a...

"Mixed declaration and code" warning, is it worth addressing?

I've recently enabled -pedantic option on gcc and now I've got about two or three pages of "ISO C90 forbids mixed declaration and code" warnings. My goal with this project is to be able to deploy it on any mainstream system with a c compiler, so I realize it wouldn't be wise to assume that C99 will be supported everywhere, but is it eve...

"warning: initialization makes pointer from integer without a cast". But I don't think it does...

I'm getting a strange compile warning. It's intermittent, and doesn't appear every build. I get the warning "initialization makes pointer from integer without a cast" for the following line: callbackTable *callbacks = generateLoggingCallback(); and, for completeness, this gives the same outcome callbackTable *callbacks; callbacks = g...

How to I fix this "may not respond" warning?

Hi, How do I get rid of these warnings "Warning:'UIButton' may not respond to '-setPosition:' and "Warning:'UIButton' may not respond to '-addAnimation:forKey' I get them here: - (void)monBtnIn { [monButton setPosition:CGPointMake(113.5,256.5)]; [monButton addAnimation:[self monInAnimation] forKey:@"position"...

Where to add -Wall and -Wextra in Xcode 3.1.4

I'm trying to figure out where to add extra warning flags like -Wall and -Wextra in Xcode, I'm using version 3.1.4 on Leopard. Apple's documentation is for an old version, if I follow their instructions it takes me to a completely different window than what they show. Also they have a screenshot of a checklist of specific warning flags...

Why does WebService::Mappoint complain about "Not a HASH reference" when I call new()?

I've inherited some Perl code that makes a web service call to Microsoft's Mappoint wbeservice, but after a recent upgrade, it's started failing with the ever cryptic: Not a HASH reference at /usr/lib/perl5/site_perl/5.8.0/WebService/Mappoint.pm line 35. Without posting the full code of the module (after all, WebService::Mappoint i...

Boolean expression order of evaluation in Java?

Suppose I have the following expression String myString = getStringFromSomeExternalSource(); if (myString != null && myString.trim().length() != 0) { ... } Eclipse warns me that myString might be null in the second phrase of the boolean expression. However, I know some that some compilers will exit the boolean expression entirely if t...

How To Ignore Warnings With GCJ

I have some classes that implement interfaces, some of which have methods whose parameters are by definition unused in the particular class implementation. e.g. A "Shape" interface may define a "contains(point)" method, but my particular class defines a line, which cannot contain anything since it's 1-dimensional, so it always returns fa...

Help deciphering an NSString "passing argument ... from distinct Objective-C type warning"

Hi all, I am having trouble deciphering a "passing argument ... from distinct Objective-C type warning". I have a constant string declared as: extern NSString * const URL_1; and defined as: NSString * const URL_1 = @"http://someurl"; If I, say, assign that constant to an NSString as follows: NSString *URL = nil; ... URL = [[NSSt...

Significance of const keyword positioning in variable declarations

What is the significance of the positioning of the const keyword when declaring a variable in Objective-C, for example: extern const NSString * MY_CONSTANT; versus extern NSString * const MY_CONSTANT; Using the first version in assignments produces warnings about "qualifiers from pointer target type" being discarded so I'm assum...

MSVCRTD.lib(cpu_disp.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators

Hi I know this question has popped up before but I could not find a good answer so I try here. I have a pure C dll (Win32) and I get this warning when compiling: MSVCRTD.lib(cpu_disp.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators Everything seems to work just fine but I am conce...

'out' issue in VB.NET

When in C# we have the out and ref parameter options, in VB there is a only one: ByRef. Now, little 'problem' when trying to 'eliminate' the compiler warning saying that test was not initialized before passing as argument: Dim test As MyParsableClass ' = Nothing need imperatively?? ' ' some code ... ' MyParsableClass.TryParse("value",...