Reputation: 85
I get a C4503 warning message ("decorated name length exceeded, name was truncated", 3 times) when compiling the following C++ code in VS 2010, with Boost 1.4.9:
#include <vector>
#include <map>
#pragma warning (push, 1)
#include <boost/units/quantity.hpp>
#include <boost/units/si/plane_angle.hpp>
#pragma warning (pop)
using namespace boost::units;
typedef std::pair<quantity<si::plane_angle>, quantity<si::plane_angle> > Section;
std::vector<Section> getEmptyVector()
{
std::vector<Section> sections;
return sections;
}
The thing that puzzles me is that the warning goes away only when I remove the #pragma
directives. Is there an explanation for this, or does the compiler have a bug?
Upvotes: 1
Views: 5541
Reputation: 2635
The correct answer to this question can be found in the MSDN documentation:
The pragma warning( pop ) pops the last warning state pushed onto the stack. Any changes that you made to the warning state between push and pop are undone.
Any changes to the warning state between push and pop are undone. Which means, whatever changes the boost-headers themselves make (and they disable 4503 apparently) is undone. You could reinstate the disabling of 4503 after your pop.
Upvotes: 0
Reputation: 1542
It seems as if it's a warning the boost guys have decided to suppress for the Visual C++ compiler.
From here:
Warning: C4503 decorated name length exceeded
Suggestions: Suppress. (Note that \boost\config\compiler\visualc.hpp includes this global > suppression...)! Suppression: #pragma warning(disable:4503)
Now for the complier. Note the following code:
#pragma warning (push, 1)
#pragma warning (disable:4503)
// C4503.cpp
// compile with: /W1 /EHsc /c
// C4503 expected
#include <string>
#include <map>
class Field{};
typedef std::map<std::string, Field> Screen;
typedef std::map<std::string, Screen> WebApp;
typedef std::map<std::string, WebApp> WebAppTest;
typedef std::map<std::string, WebAppTest> Hello;
Hello MyWAT;
#pragma warning (pop)
I just tweaked the Microsoft help example for this warning
if you put the #pragma warning (disable:4503)
after the push, you get the warning. If you put it before, there are no warnings. That means the code above generates C4503 warnings, even though it was disabled.
Upvotes: 2
Reputation: 16153
Boost causes that error a lot and IIRC (from v 1.2ish) it manages warnings in the boost libraries that are considered harmless. You are seeing that warning because you're doing something they don't expect and fouling up their warning management.
Upvotes: 1