分页: 1 / 1

C++初级问题

发表于 : 2006-04-25 23:27
shaken
就这么一个简单的屏幕输出,提示了一大串的错误提示:
#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’ 没有命名一个类型

发表于 : 2006-04-25 23:52
ifg
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]

发表于 : 2006-04-26 0:18
shaken
有点迷糊,能不能解释一下

发表于 : 2006-04-26 0:35
ifg
重點在於.....跑起來一切正常阿.
ifg@ubuntu:/tmp/c$ g++ -o test test.c
看看你是不是用錯compiler了?

发表于 : 2006-04-30 2:26
shaken
我是用g++的,版本应该是:4.0.2。
查它的版本是什么时候的用什么命令参数阿??

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

发表于 : 2006-05-11 15:41
fjtsea
兄台:你的问题十分没问题。

$ 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)