系统和指针

来源:互联网 发布:号码归属地数据库excel 编辑:程序博客网 时间:2024/06/14 21:47

1. 32位和64位环境的主要区别在于所使用的C语言数据类型的模型

  • 32位数据类型使用ILP32模型,其中int、long和指针宽度为32位。
  • 64位数据类型使用LP64模型,其中long和指针的宽度为64位,其他所有基础数据类型仍然与32位实现的数据类型相同;

2. restric VS const

One of the new features in the recently approved C standard C99, is the restrict pointer qualifier. This qualifier can be applied to a data pointer to indicate that, during the scope of that pointer declaration, all data accessed through it will be accessed only through that pointer but not through any other pointer. The ‘restrict’ keyword thus enables the compiler to perform certain optimizations based on the premise that a given object cannot be changed through another pointer. Now you’re probably asking yourself, “doesn’t const already guarantee that?” No, it doesn’t. The qualifier const ensures that a variable cannot be changed through a particular pointer. However, it’s still possible to change the variable through a different pointer.
也就是说restric保证的是一块内存只有一个指针来引用,其它指针不能引用自然不能修改该内存; 而const保证的是通过指定的某个指针无法对该内存数据进行修改,但可以通过其它的指针进行迂回的修改。

0 0
原创粉丝点击