C++初级问题

C、C++和Java语言
回复
shaken
帖子: 48
注册时间: 2006-03-24 2:05
来自: 浙江温州
送出感谢: 0
接收感谢: 0

C++初级问题

#1

帖子 shaken » 2006-04-25 23:27

就这么一个简单的屏幕输出,提示了一大串的错误提示:
#include <iostream>
#include <string>
using namespace std;

int main()

{

cout << "Fucj";

return 0;

}
错误提示类似以下,还有很多,截取一部分。我怀疑是库文件又问题,但是又不知道问题在哪里:
/usr/include/c++/4.0.2/bits/char_traits.h: At global scope:
/usr/include/c++/4.0.2/bits/char_traits.h:66: 错误:‘streamoff’ in namespace ‘std’ does not name a type
/usr/include/c++/4.0.2/bits/char_traits.h:67: 错误:‘mbstate_t’ in namespace ‘std’ does not name a type
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static typename __gnu_cxx::_Char_types<_CharT>::int_type __gnu_cxx::char_traits<_CharT>::eof()’:
/usr/include/c++/4.0.2/bits/char_traits.h:139: 错误:‘EOF’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static typename __gnu_cxx::char_traits<_CharT>::char_type* __gnu_cxx::char_traits<_CharT>::move(_CharT*, const _CharT*, size_t)’:
/usr/include/c++/4.0.2/bits/char_traits.h:186: 错误:‘memmove’ 不是 ‘std’ 的成员
/usr/include/c++/4.0.2/bits/char_traits.h: At global scope:
/usr/include/c++/4.0.2/bits/char_traits.h:236: 错误:‘streamoff’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:237: 错误:‘mbstate_t’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static int std::char_traits<char>::compare(const char*, const char*, size_t)’:
/usr/include/c++/4.0.2/bits/char_traits.h:253: 错误:‘memcmp’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static size_t std::char_traits<char>::length(const char*)’:
/usr/include/c++/4.0.2/bits/char_traits.h:257: 错误:‘strlen’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static const char* std::char_traits<char>::find(const char*, size_t, const char&)’:
/usr/include/c++/4.0.2/bits/char_traits.h:261: 错误:从类型 ‘const void*’ 到类型 ‘void*’ 的转换无效
/usr/include/c++/4.0.2/bits/char_traits.h:261: 错误: initializing argument 1 of ‘void* std::memchr(void*, int, size_t)’
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static char* std::char_traits<char>::move(char*, const char*, size_t)’:
/usr/include/c++/4.0.2/bits/char_traits.h:265: 错误:‘memmove’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static char* std::char_traits<char>::copy(char*, const char*, size_t)’:
/usr/include/c++/4.0.2/bits/char_traits.h:269: 错误:‘memcpy’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static char* std::char_traits<char>::assign(char*, size_t, char)’:
/usr/include/c++/4.0.2/bits/char_traits.h:273: 错误:‘memset’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: In static member function ‘static int std::char_traits<char>::eof()’:
/usr/include/c++/4.0.2/bits/char_traits.h:290: 错误:‘EOF’ 在此作用域中尚未声明
/usr/include/c++/4.0.2/bits/char_traits.h: At global scope:
/usr/include/c++/4.0.2/bits/char_traits.h:304: 错误:‘wint_t’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:305: 错误:‘streamoff’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:307: 错误:‘mbstate_t’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:346: 错误:expected ‘,’ or ‘...’ before ‘&’ token
/usr/include/c++/4.0.2/bits/char_traits.h:348: 错误:‘int_type’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:352: 错误:expected ‘,’ or ‘...’ before ‘&’ token
/usr/include/c++/4.0.2/bits/char_traits.h:355: 错误:‘int_type’ 没有命名一个类型
/usr/include/c++/4.0.2/bits/char_traits.h:358: 错误:‘int_type’ 没有命名一个类型
Ubuntu Daper+Windows XP pro SP2
CPU: Intel Celeron D 2.66G
MB: ECS 845PE-A800
DRAM: Kingston DDR400 512M+DDR333 256M
VGA: ATI Rage 128 8M
HD: Seagate 80G
usb HD: 60G+40G
Monitor: Philips 107T
ifg
帖子: 4
注册时间: 2006-03-17 3:23
送出感谢: 0
接收感谢: 0

#2

帖子 ifg » 2006-04-25 23:52

ifg@ubuntu:/tmp/c$ cat test.c

代码: 全选

#include <iostream>
#include <string>
using namespace std;

int main()

{

cout << "Fucj";

return 0;

}

ifg@ubuntu:/tmp/c$ g++ -o test test.c
ifg@ubuntu:/tmp/c$ ./test
Fucjifg@ubuntu:/tmp/c$

--
ifg@ubuntu:/tmp/c$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --with-tune=pentium4 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)[/code]
shaken
帖子: 48
注册时间: 2006-03-24 2:05
来自: 浙江温州
送出感谢: 0
接收感谢: 0

#3

帖子 shaken » 2006-04-26 0:18

有点迷糊,能不能解释一下
Ubuntu Daper+Windows XP pro SP2
CPU: Intel Celeron D 2.66G
MB: ECS 845PE-A800
DRAM: Kingston DDR400 512M+DDR333 256M
VGA: ATI Rage 128 8M
HD: Seagate 80G
usb HD: 60G+40G
Monitor: Philips 107T
ifg
帖子: 4
注册时间: 2006-03-17 3:23
送出感谢: 0
接收感谢: 0

#4

帖子 ifg » 2006-04-26 0:35

重點在於.....跑起來一切正常阿.
ifg@ubuntu:/tmp/c$ g++ -o test test.c
看看你是不是用錯compiler了?
shaken
帖子: 48
注册时间: 2006-03-24 2:05
来自: 浙江温州
送出感谢: 0
接收感谢: 0

#5

帖子 shaken » 2006-04-30 2:26

我是用g++的,版本应该是:4.0.2。
查它的版本是什么时候的用什么命令参数阿??
Ubuntu Daper+Windows XP pro SP2
CPU: Intel Celeron D 2.66G
MB: ECS 845PE-A800
DRAM: Kingston DDR400 512M+DDR333 256M
VGA: ATI Rage 128 8M
HD: Seagate 80G
usb HD: 60G+40G
Monitor: Philips 107T
fjtsea
帖子: 14
注册时间: 2006-02-26 10:35
送出感谢: 0
接收感谢: 0

兄台:你的问题十分没问题。

#6

帖子 fjtsea » 2006-05-11 15:41

兄台:你的问题十分没问题。

$ g++ -o test test.cpp
$ ls
test test.cpp
$ ./test
Fucj$

查它的版本是什么时候的用: g++ -v
$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
回复

回到 “C/C++/Java”