免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: 小蟹子
打印 上一主题 下一主题

百思不得其解的问题.请大家帮忙(在线等^,问题已经解决) [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-06-29 10:03 |只看该作者
原帖由 小蟹子 于 2007-6-29 09:56 发表
楼上的意思是这样的吧。
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
        long long a = 200;
        long long b = 100;
        long long c = lla ...

把g++的错误输出帖上来

论坛徽章:
0
12 [报告]
发表于 2007-06-29 10:03 |只看该作者
我这边,两种方法都没问题

论坛徽章:
0
13 [报告]
发表于 2007-06-29 10:05 |只看该作者
原帖由 antonym55 于 2007-6-29 10:03 发表
我这边,两种方法都没问题

我的也是,不知道lz怎么弄出了错误报告来了

论坛徽章:
0
14 [报告]
发表于 2007-06-29 10:08 |只看该作者
[guo@yw2-zqpmstest ~]$ cat test.cpp
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
        long long a = 200;
        long long b = 100;
        long long c = llabs(a-b);
        cout<<"c = "<<c<<endl;
        return 0;
}
[guo@yw2-zqpmstest ~]$ g++ -o doTest test.cpp
test.cpp: In function `int main()':
test.cpp:9: error: call of overloaded `llabs(long long int)' is ambiguous
/usr/include/stdlib.h:784: note: candidates are: long long int llabs(long long int)
/usr/lib/gcc/i386-redhat-linux/3.4.5/../../../../include/c++/3.4.5/cstdlib:156: note:                 long long int __gnu_cxx::llabs(long long int)
[guo@yw2-zqpmstest ~]$

论坛徽章:
0
15 [报告]
发表于 2007-06-29 10:11 |只看该作者
各位的编译器是什么样的,是不是我编译器的问题呢?
怎么看编译器的信息,我把我的编译器信息也贴出来。

论坛徽章:
0
16 [报告]
发表于 2007-06-29 10:13 |只看该作者
再试一下用
::llabs()

std::llabs()

我的g++版本为g++ (GCC) 3.2.3
不用冠以域限定符可以编译通过

论坛徽章:
0
17 [报告]
发表于 2007-06-29 10:20 |只看该作者
原帖由 小蟹子 于 6/29/2007 10:11 发表
各位的编译器是什么样的,是不是我编译器的问题呢?
怎么看编译器的信息,我把我的编译器信息也贴出来。


  1. [weigw@TEST src]$ g++ -v
  2. Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
  3. Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
  4. Thread model: posix
  5. gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
  6. [weigw@TEST src]$ gcc -v
  7. Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
  8. Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
  9. Thread model: posix
  10. gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
复制代码

论坛徽章:
0
18 [报告]
发表于 2007-06-29 10:24 |只看该作者
楼上的,你说的两种方法都能通过。
奇怪,为什么我这边就必须加域名呢?
那我要用c++的llabs函数该怎么办?

论坛徽章:
0
19 [报告]
发表于 2007-06-29 10:25 |只看该作者
[guo@yw2-zqpmstest ~]$ g++ -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
[guo@yw2-zqpmstest ~]$ gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
[guo@yw2-zqpmstest ~]$

以上是我的编译器信息,请帮我分析原因。

论坛徽章:
0
20 [报告]
发表于 2007-06-29 10:29 |只看该作者
原帖由 小蟹子 于 2007-6-29 10:24 发表
楼上的,你说的两种方法都能通过。
奇怪,为什么我这边就必须加域名呢?
那我要用c++的llabs函数该怎么办?

因为你用了 using namespace std;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP