LoveUnix » 编程开发 & Rational » 请在ibm aix下写过STL程序的人帮忙!!小弟碰到麻烦了!
让LU留住您的每

一天 让LU博客留住您的每一天
2006-9-26 22:51 xuqing1980
请在ibm aix下写过STL程序的人帮忙!!小弟碰到麻烦了!

刚刚写了第一个程序hello world,编译就出了很多问题,后来用了cc_r进行编译,总算通过.
现在写了一个stl向量的小程序,但是报错,我想问问,出了什么问题!请大家帮忙!
程序如下:
#include "stdio.h"
#include <vector>
using namespace std;
void main(void)
{
int a[10]={1,3,9,13,15,3,21,18,3,38};
vector<int> vec(a,a+10);
vector<int>::iterator iter=vec.begin();
for(;iter!=vec.end();iter++)
printf("%d ",*iter);
printf("\n");
printf("hello world\n");
}

编译及错误提示如下:
$cc_r -o hello hello.c
"hello.c", line 2.10: 1506-296 (S) #include file <vector> not found.
"hello.c", line 3.1: 1506-166 (S) Definition of function using requires parentheses.
"hello.c", line 3.7: 1506-276 (S) Syntax error: possible missing '{'?
"hello.c", line 7.16: 1506-046 (S) Syntax error.
"hello.c", line 7.9: 1506-045 (S) Undeclared identifier vector.
"hello.c", line 8.16: 1506-046 (S) Syntax error.
"hello.c", line 8.22: 1506-045 (S) Undeclared identifier iterator.
"hello.c", line 9.20: 1506-021 (S) Expecting struct or union.
"hello.c", line 9.14: 1506-045 (S) Undeclared identifier iter.

2006-9-29 16:45 tdx_rong
先确认一下cc_r能编译c++的代码吗(cc_r没见过,不知道可以做什么)

2006-9-30 12:35 triphop
将你的.c更改为 .cc,然后再编译

2006-10-30 19:19 jxufe
/usr/include/vector.h文件不存在
其他的错误都是因为这个头文件不存在而找不到相应的结构说明而引起的

2006-11-9 08:14 hsia
确认已经安装 IBM C++

基本上,随操作系统免费带的编译器只能编译C语言,C++是需要买来安装的。
using namespace std;  // 这句也报错,说明,用的不是C++编译器。
另外,C++源程序的后缀,应该是 .cpp才对。

[[i] 本帖最后由 hsia 于 2006-11-9 08:16 编辑 [/i]]

2006-11-10 11:30 wanghi
肯定是没有安装

页: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.