Brian Postow
Brian Postow

Reputation: 12167

How do I get rid of these warnings?

This is really several questions, but anyway...

I'm working with a big project in XCode, relatively recently ported from MetroWorks (Yes, really) and there's a bunch of warnings that I want to get rid of. Every so often an IMPORTANT warning comes up, but I never look at them because there's too many garbage ones. So, if I can either figure out how to get XCode to stop giving the warning, or actually fix the problem, that would be great. Here are the warnings:

Upvotes: 1

Views: 3342

Answers (4)

Jon Steinmetz
Jon Steinmetz

Reputation: 4124

I discovered that at least as of Xcode 3.2.4 you can make the warning go away by using a number of characters in the constant that is the correct length for the type.

For example I had a constant that was only 3 chars long 'TT2' and it was giving me the multi-character character constant error. Adding 0's to the constant made the errors go away, like so: '\0TT2'.

Upvotes: 0

John Marshall
John Marshall

Reputation: 6995

"multi-character character constant"
This one is obvious. The problem is that I actually NEED multi-character constants...

Compile with -Wno-multichar -- add it to Other Warning Flags, and leave the Four Character Literals warning switched off.

Of course, whether this legacy code's multi-character character constants actually mean the same thing as they did under Metrowerks probably on a different architecture... is an open question.

Upvotes: 3

Mark B
Mark B

Reputation: 96233

Items in <map.h> are in the global namespace while items in <map> are in the std namespace. Most likely you were just referring directly to the global versions and when you switched to <map> you were no longer seeing them because they moved to std::. In source files add a using namespace std to move on quickly. In headers you'll need to qualify uses of map-related items with std::.

I think you'll need to qualify the literal constant value with a trailing UL so it knows the correct type of the literal.

Most likely the enums are in two separate OS defined anonymous enums. You can static_cast them to quiet the warning.

No idea on the multi-byte chars.

Can you disable -fwritable-strings? Can you refactor the code that needs to modify constant strings?

Upvotes: 3

ndim
ndim

Reputation: 37747

That decimal constant is written like 3111222333UL?

Upvotes: 1

Related Questions