哪位朋友用64位版的vc,帮我测下帮我测一下sizeof(ptrdiff_t)的值?

ljhhh0123 2011-09-28 10:56:09
我也是要回答坛友的一个问题,来判断系统是16位,32位还是64位的。
样例程序已经写好,拜托了 。
#include <iostream>
#include <cstddef>

int main(int argc, char* argv[])
{
std::cout << sizeof(ptrdiff_t) << std::endl;
return 0;
}
...全文
118 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 akirya 的回复:]

引用 4 楼 ljljlj 的回复:

The types used for size_t and ptrdiff_t should not have an integer conversion rank
greater than that of signed long int unless the implementation supports objects
large enough……
[/Quote]
呃有点错误,后一句应该是
你的32位程序咋知道在64位系统上跑,还能根据系统自适应改变 数据类型的大小?

再说了你都指定要64位的VC了,判断还有啥意义?
32位系统上必须用32位编译器,必须输出32位的程序。
64位系统上必须用64位编译器,必须输出64位的程序。
还不如直接用WIN32 WIN64宏判断来的快。
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ljljlj 的回复:]

The types used for size_t and ptrdiff_t should not have an integer conversion rank
greater than that of signed long int unless the implementation supports objects
large enough to make this necessar……
[/Quote]
64位系统上跑32位程序,就跟32位系统上跑32位程序一模一样
你的32位程序咋知道在64位系统上跑,还能根据系统自适应指针大小?
ljhhh0123 2011-09-28
  • 打赏
  • 举报
回复
The types used for size_t and ptrdiff_t should not have an integer conversion rank
greater than that of signed long int unless the implementation supports objects
large enough to make this necessary.
以上是C99修正草案3标准文档的说明(文档代号n1256)。
以下是来自msdn的说法,
在 64 位 Windows 操作系统中,size_t、time_t 和 ptrdiff_t 是 64 位值。
引自:http://msdn.microsoft.com/zh-cn/library/3b2e7499(v=vs.90).aspx

真没朋友用64位vc?
机智的呆呆 2011-09-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 akirya 的回复:]
引用楼主 ljljlj 的回复:
我也是要回答坛友的一个问题,来判断系统是16位,32位还是64位的。
样例程序已经写好,拜托了 。
C/C++ code
#include <iostream>
#include <cstddef>

int main(int argc, char* argv[])
{
std::cout << sizeof(ptrdiff_t) << std:……
[/Quote]
ptrdiff_t来实现来定义的。只要大于−65535小于65535即可
  • 打赏
  • 举报
回复
[Quote=引用楼主 ljljlj 的回复:]
我也是要回答坛友的一个问题,来判断系统是16位,32位还是64位的。
样例程序已经写好,拜托了 。
C/C++ code
#include <iostream>
#include <cstddef>

int main(int argc, char* argv[])
{
std::cout << sizeof(ptrdiff_t) << std::endl;
return 0……
[/Quote]
不用试,你的方法错误。
ljhhh0123 2011-09-28
  • 打赏
  • 举报
回复
难道没人用64位vc么?
看来现在还是32位的天下啊。

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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