views:

267

answers:

4

I am in the habit of removing all warning reported in my code. I just like a clean build if possible. I used

#pragma comment(lib,"some.lib");

I get this warning:

warning c4081: expected 'newline'; found ';'

I am uncertain why that would create a warning. Could I get help on removing it?

+1  A: 
#pragma warning(disable: 4081)

will disable the warning. but I can't repro the warning unless the syntax of the comment is wrong.

#pragma comment(lib "some.lib") 

gives me warning 4081 but

#pragma comment(lib, "some.lib") 

does not.

What is the text of your warning message?

Edit: I see now, forget adding a #pragma warning, just remove the ; from the end of the comment line. it's a syntax error.

John Knoeller
warning c4081: expected 'newline'; found';' this is one of the warnings i get.
@user245823: Please add this to your question.
quamrana
A: 

You can selectively, and temporarily disable all warnings like this:

#pragma warning(push, 0)        

#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/bind.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/device/back_inserter.hpp>

#pragma warning(pop)

Instead of 0 you can optionally pass in something like:

#pragma warning( push )
#pragma warning( disable : 4081)
#pragma warning( disable : 4706 )
#pragma warning( disable : 4707 )
// Some code
#pragma warning( pop ) 
Brian R. Bondy
Thats a pretty horrible solution. Don't like your errors, just disable them. Don't worry about what they mean, if you don't understand them, just throw them away! Warnings are there for a reason. In his case, he probably misplaced that semicolon. In other cases, it could be that it's warning about a miscast. Hiding the errors doesn't mean it's not a problem for the compiler.
Daniel Goldberg
@Daniel Goldberg: I am not saying to always hide your warnings. Please do not imply that on my answer. I'm just saying this is a possibility when you have no way to get rid of the warning, and it is not your fault. For example maybe you have boost header files that you aren't allowed to change.
Brian R. Bondy
+1, because I do something like this when I use boost.
GMan
A: 

You have not mentioned the compiler type and version, but I think you need to put the name without the ".lib" in second parameter (see here)

AureliusMarcus
+4  A: 

Its the semi-colon at the end of the line. Its not needed for #pragma.

edit: The warning says it all: Expected a newline at the end of the pragma, but found a semi-colon instead.

Tested with VS2008

quamrana