CC编译问题

bulcsu 2008-10-30 04:45:30
使用SUN Stuidio11的编译器进行编译,出现如下问题:
The name istream is ambiguous, istream and std::istream
请问是何原因?谢谢!
...全文
127 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bulcsu 2008-11-05
  • 打赏
  • 举报
回复
没人回答吗,已经困惑很多天了。
bulcsu 2008-10-31
  • 打赏
  • 举报
回复
补充一下:
因为我编译的代码比较老,因此还有iostream.h的定义。而在目前的编译器里面有一个RW_NO_IOSTD,它的定义是:
*** RW_NO_IOSTD: Defined if you have the "original flavor" iostreams
package, as opposed to the emerging draft ANSI C++ standard.
也就是说如果我定义了这个宏的话,现在的C++标准库就不会和以前的冲突,那我应该在哪里定义呢?
bulcsu 2008-10-31
  • 打赏
  • 举报
回复
完整的提示是这样的:
"/sunstudio/SUNWspro/prod/include/CC/rw7/rw/rstream.h", line 46: Error: The name istream is ambiguous, istream and std::istream.

我是不是得修改/sunstudio/SUNWspro/prod/include/CC/rw7/rw/rstream.h 这个文件?

这个文件的头是这样写的:
#include "rw/defs.h"

# ifdef __GLOCK__
# include <iostream.hxx>
# else
# ifndef RW_NO_IOSTD
# include <iostream>
# else

# include <iostream.h>
# endif
# endif
wuyu637 2008-10-30
  • 打赏
  • 举报
回复
参考如下方式来解决:(看一下那个帖子,命名空间的问题)

I suggest you to use the ISO/ANSI Standard C++ recommendation for using the
Standard C++ Library:

- include the header files without the .h extension
- after this, explict that you will use the namespace std

Example:

#include <iostream>
#include <sstream> //for streamers
#include <string>

using namespace std;

//your code goes here

In addition, the ostrstream class is deprecate. You must replace it with
std:stringstream. This one is declared in the <sstream> header file.

Please, check if your compiler is compliant with the last standardization
of C++. If not so, try to use a more updated compiler. For instance, you
can download the gcc GNU compiler from www.gnu.org. It's free and fully adheres
to the last C++ standardization (199. When I use gcc under Unix, my programs
that use the Standard C++ Library needs to be linked with the -lstdc++.

Luis

http://forums.devx.com/showthread.php?t=92319

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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