指针,并且,如果尺寸大小取决于该架构的 [英] Size of pointers and if that size is dependent of the architecture

查看:135
本文介绍了指针,并且,如果尺寸大小取决于该架构的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,遗憾的问题,更像是一个普通文化一(还没有找到precise答案)。

如果我有这样的事情

 的char *场

 无效*场

 双指针


  • 指针的大小是一样的吗? (据我从大学记得是4字节,但是......)

  • 取决于CPU的架构?
  • 是对指针的大小相同
  • 如果我指向一个数据结构,指针本身的大小是一样的,是不是?

假设在C例子(我会倾向于认为,这将是一个不直接处理指针其他语言一样)


解决方案

  

指针的大小是一样的吗? (据我从大学记得是4字节,但是......)


不一定相同,并且不一定4字节:<一href=\"http://stackoverflow.com/questions/1241205/are-all-data-pointers-of-the-same-size-in-one-platform\">are在一个平台上相同尺寸的所有数据指针?


  

根据CPU的架构是对指针的大小相同?


从archtecture各不相同的架构。即使在相同的硬件就可以从操作系统到操作系统(例如32位和64位)而变化。


  

如果我指向一个数据结构,指针本身的大小是一样的,是不是?


再次不一定:<一href=\"http://stackoverflow.com/questions/1241205/are-all-data-pointers-of-the-same-size-in-one-platform\">are在一个平台上相同尺寸的所有数据指针?

Well, sorry for the question, is more like a general culture one (haven't found precise answers).

If I have something like

char * Field

or

void * Field

or

double pointers

  • The size of the pointer is the same? (as far I remember from college it was 4 bytes but ...)
  • Is the size of the pointer the same depending of the architecture of the CPU?
  • If I point to a data structure, the size of the the pointer itself is the same, isn't it?

Assume the examples in C (I would be prone to believe that it will be the same for other languages that does not handle pointers directly)

解决方案

The size of the pointer is the same? (as far I remember from college it was 4 bytes but ...)

Not necessarily the same and not necessarily 4 bytes: are all data pointers of the same size in one platform?

Is the size of the pointer the same depending of the architecture of the CPU?

It varies from archtecture to architecture. Even on the same hardware it can vary from operating system to operating system (e.g. 32-bit vs 64-bit).

If I point to a data structure, the size of the the pointer itself is the same, isn't it?

Again, not necessarily: are all data pointers of the same size in one platform?

这篇关于指针,并且,如果尺寸大小取决于该架构的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆