我想爲我的C++項目使用Boost的lexical_cast,但運行到使用Visual Studio 2010 Professional的編譯錯誤。編譯錯誤提升throw_exception.hpp
錯誤如下:
1> VLGUI_Frame.cpp
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(54): error C2143: syntax error : missing ')' before 'constant'
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(54): error C2143: syntax error : missing ';' before 'constant'
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(54): error C2988: unrecognizable template declaration/definition
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(54): error C2059: syntax error : 'constant'
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(54): error C2059: syntax error : ')'
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(72): error C2143: syntax error : missing ';' before '{'
1>c:\users\dev\external\boost_1_46_1\boost\throw_exception.hpp(72): error C2447: '{' : missing function header (old-style formal list?)
1>
1>Build FAILED.
這裏是使用lexical_cast的代碼(這是沒有關係的,但誰知道它可以幫助)
#include "boost/lexical_cast.hpp"
...
std::string Frame::toString()
{
std::string str = "";
try
{
str = VLString::combine(12,
m_Name.c_str(),
" : Dimensions[",
boost::lexical_cast<std::string>(m_Rect.width).c_str(),
",",
boost::lexical_cast<std::string>(m_Rect.height).c_str(),
"] : Loc[",
boost::lexical_cast<std::string>(m_Rect.x).c_str(),
",",
boost::lexical_cast<std::string>(m_Rect.y).c_str(),
"] : NumChildren[",
boost::lexical_cast<std::string>(m_Children.size()).c_str(),
"]");
}
catch(boost::bad_lexical_cast &)
{
str = VLString::combine(2,
m_Name.c_str(),
" : lexical_cast failed");
}
return str;
}
不幸的是我沒有足夠的經驗來幫助Boost自己診斷這個問題。我做了必須的谷歌,沒有結果。
謝謝你的幫助。
雖然在Boost中可能存在嚴重的構建錯誤,但這種情況極不可能...... – 2011-05-03 04:40:45