I have a warning in my C++ code, regarding the use of FLT_MAX. The code is (very simply):
const float a_lot = FLT_MAX;
The generated warning is:
warning C4756: overflow in constant arithmetic
And it doesn't help if I change the code to:
const float a_lot = std::numeric_limits<float>::max();
I'm using Microsoft Visual Studio 2...
Probably an easy beginners question: I want to add the compiler flag /EHsc to my project and tried both
SET_TARGET_PROPERTIES(name_of_my_project PROPERTIES COMPILER_FLAGS "/EHsc")
and
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
in my CMakeLists.txt. With both, CMake generates a Visual Studio Solution without complaining.
EDI...
I am writing some C code which is expected to compile on multiple compilers (at least on MSVC and GCC). Since I am beginner in C, I have all warnings turned on and warnings are treated as errors (-Werror in GCC & /WX in MSVC) to prevent me from making silly mistakes.
When I compiled some code that uses strcpy on MSVC, I get warning lik...
I just upgraded our project to JDK 1.6, and on compilation, I have a test class that implements java.awt.Toolkit and implements the methods to do nothing special (other than capture the call to the beep command).
(This is an old test that should probably be rewritten in several ways (either mock it or wrap that functionality in a simpl...
In my iPhone apps I regularly do this in xCode v3.2.3:
Declare a BOOL variable in the *.h file
Use @property in the same *.h file.
Use @sythesize in the matching *.m file.
I accidentally forgot to do #1... but it still complied fine. 0 warnings. 0 errors. 0 analyzer errors.
How can that be? Shouldn't my code to loaded with compil...
I have just installed the Windows SDK v7.1 (MSVC 10.0) and running my code through (almost) full warning level (W3, default for qmake's CONFIG += warn_on) and am surprised about warning C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
In the following code, stream is an std::istream and token is a std::strin...
I've got a continuous integration setup using Hudson and lately I've configured the jobs to use svn update to get the latest version of the code. I really like this approach since it allows msbuild to version appropriately and only build the effected assemblies.
However, I've noticed that since I'm not doing a build of all the assembli...
I've just been debugging a problem with a function that returns a string that has got me worried. I've always assumed that the implicit Result variable for functions that return a string would be empty at the start of the function call, but the following (simplified) code produced an unexpected result:
function TMyObject.GenerateInfo: s...
I have a huge number of source files that are all lacking a newline at the end. How do I automatically add a newline to the end of each of them?
Some may already have a newline, so it should only be added if necessary.
I'm probably not looking for code, per se, but just something I can run in Terminal to add the necessary newlines (or ...
test.c(6) : warning C4013: 'add' undefined; assuming extern returning int
I've encountered many times when an undefined function will report an error,thus stopping the building process.
Why this time just a warning?
...
I have the following code, for an embedded platform where an int is 16 bits and a long int is 32 bits:
#define MULTIPLIER 0x1000
static void my_function(uint16_t i, void *p)
{
uint32_t start = MULTIPLIER * i;
...
}
My compiler gives me the warning:
Warning 1 : lower precision in wider context: '*'
for this line.
What does...
Hi, I'm having some problems working with NSStrings in Objective C... the code below returns a warning, saying:
"'NSString' may not respond to '-stringByReplacingOccurancesOfString:withString:"
NSString* NewWord = [Word stringByReplacingOccurancesOfString:@"!"
withString:@""];
What ...
I am getting an compiler warning / error at compile time using NetBeans 6.9 with some Java code that is:
run: 2010-07-27 22:43:47.392 java[18743:903] NSKeyBindingManager: Bad key binding atom for '6' = 'D' BUILD SUCCESSFUL (total time: 5 seconds)
The code still runs. Is this anything to worry about? I would post the code, but it se...
In Visual C++, it's possible to use #pragma warning (disable: ...). Also I found that in GCC you can override per file compiler flags. How can I do this for "next line", or with push/pop semantics around areas of code using GCC?
...
The first comment on a feature request for g++ says, "Starting with 4.5 you can disable a class of warnings in the source."
I looked through the 4.5.0 manual, but I can't find the syntax.
What is the syntax in g++ 4.5 and later to suppress individual warning classes in the source?
...
When I put the code below in NetBeans, NetBeans gives me a warning next to it saying "Accessing static method sleep".
try {
Thread.currentThread().sleep(2000);
}
catch(InterruptedException ie){
//continue
}
Am I doing something wrong? Should I be calling this differently? I'm n...
I am working on deprecating a set of Java classes so they aren't used anymore. I don't want to turn off the compiler warnings for deprecated usage, but I'm finding that if one of my deprecated classes imports another deprecated class I get a warning on that, too. I don't want to modify the code I'm deprecating, but I also don't want the ...
I am receiving the following warning when compiling a Qt project, but ONLY on Mac OS X with GCC. Windows with MinGW and Linux with GCC do not emit this warning.
/Library/Frameworks/QtCore.framework/Versions/4/Headers/qtextcodec.h:175: warning: 'QCoreXmlStreamWriter' is already a friend of 'QTextEncoder'
Why is this showing up and how c...
I've got code that looks something like this, where addr is a sockaddr*:
struct sockaddr_in *sin = (struct sockaddr_in *) addr;
const char *IP=inet_ntoa(sin -> sin_addr);
I believe this is very typical code for using Berkeley sockets.
However, when I compile this, I'm getting the following warning:
dereferencing pointer 'sin' does br...
Hi Everyone,
I took over an iPhone project recently that was developed prior iOS4. I'm wondering if XCode would prompt warnings or errors on compile. It currently succeeds with "No issues" when built so is it safe to assert that it contains no deprecated code? Or is there a setting to be set on XCode to warn on compile for deprecated co...