在Dev-C++下使用Boost库编译问题,先上50分!

efoxxx 2002-03-29 10:18:03
就用《程序员》上的例子,编译竟然出了错误,向各位请教了。

#include <boost/lexical_cast.hpp>
#include <iostream>
#include <string>

int main(void)
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.12");
std::cout<<a<<std::endl;
std::cout<<b<<std::endl;

system("PAUSE");
return 0;
}

编译错误为:
In file included from D:/Boost/boost/lexical_cast.hpp:25,
from d:\dev-c++\mine\test_lexical_c.cpp:1:
D:/DEV-C_~1/Include/G__~1/sstream:1: parse error before `::'
In file included from d:\dev-c++\mine\test_lexical_c.cpp:1:
D:/Boost/boost/lexical_cast.hpp: In function `Target boost::lexical_cast(Source)':
D:/Boost/boost/lexical_cast.hpp:52: parse error before `;'
D:/Boost/boost/lexical_cast.hpp: In function `int boost::lexical_cast<int, const char *>(const char *)':
d:\dev-c++\mine\test_lexical_c.cpp:8: instantiated from here
D:/Boost/boost/lexical_cast.hpp:56: `interpreter' undeclared (first use this function)
D:/Boost/boost/lexical_cast.hpp:56: (Each undeclared identifier is reported only once
D:/Boost/boost/lexical_cast.hpp:56: for each function it appears in.)

...全文
151 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
babysloth 2002-04-08
  • 打赏
  • 举报
回复
我在我的机器上用gcc没问题,非常抱歉
efoxxx 2002-04-08
  • 打赏
  • 举报
回复
To: babysloth
我试过了,还是不行;gcc我已经下了最新的版本了,肯定不低。
请再帮我看看出错信息,是否我的设置有问题
babysloth 2002-04-05
  • 打赏
  • 举报
回复
呵呵,您的gcc版本是不是低了?低版本gcc的using实现有问题(见C++ VIEW,好象是第2期,http://cppview.yeah.net)。
像 x_zj() 说的那样做就可以了。
efoxxx 2002-04-01
  • 打赏
  • 举报
回复
大侠这边看过来啊
efoxxx 2002-03-31
  • 打赏
  • 举报
回复
我在bcb55下也编译通过了,只是我想在Dev-C++下编译一下,可通不过,不知是设置问题还是兼容问题,大侠指教了!
efoxxx 2002-03-31
  • 打赏
  • 举报
回复
我比较喜欢Dev-C++环境,所以请大侠说一下如何才能解决以上问题,不胜感激!
x_zj 2002-03-30
  • 打赏
  • 举报
回复
补充一点,我是在cygwin下编译的,gcc是3.04
boost 1.27
x_zj 2002-03-30
  • 打赏
  • 举报
回复
我试过了:
将using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.12");
改为:
int a = boost::lexical_cast<int>("123");
double b = boost::lexical_cast<double>("123.12");
编译时用:
g++ -o x x.cc -I $BOOSTDIR
efoxxx 2002-03-30
  • 打赏
  • 举报
回复
没有人来吗?
大家来UP一个也可以啊!

15,447

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧