C++中restrict修饰符作用
来源:互联网 发布:ubuntu怎么重新分区 编辑:程序博客网 时间:2024/06/03 12:47
今天查看POSIX的API时候,发现里面有一行
int pthread_create(pthread_t * restrict thread,const pthread_attr_t *restrictattr,void *(*start_routine)(void*),void*restrict arg);开始和不解为什么变量前面要加上restrict修饰符呢?restrict是
限制,限定; 约束,束缚
最后查询资料方得知:
restrict的定义是It can be applied only to pointers, and it indicates that a pointer is the sole initial means of accessing a data object.
restrict是一个限定符,这个关键字据说来源于古老的FORTRAN,主要用来修饰指针指向的内存不能被别的指针引用。
restrict同样可以用于数组的声明:
If you specify type qualifiers such as void foo(int * restrict a);, the C compiler expresses it with array syntax void foo(int a[restrict]); which is essentially the same as declaring a restricted pointer.
其实restrict同const或valiate一样是一个修饰符而已,告诉编译器被restrict修饰的指针所指 向的对象,只能通过这个指针或基于这个指针的其他指针进行操作,即限制访问用restrict限制的指针指向的对象只能通过这个指针访问,这对编译器的优 化很有好处。
0 0
- C++中restrict修饰符作用
- C中修饰符restrict 的用法
- C/C++ restrict修饰符
- C语言中restrict的作用
- restrict修饰符
- C++ 修饰符 restrict
- C/C++中存储类型修饰符的区别(auto、static、register、extern、volatile、restrict)
- C/C++中存储类型修饰符的区别(auto、static、register、extern、volatile、restrict)
- C中restrict关键字
- c中restrict关键字
- c/c++ cuda 编程中volatile修饰符作用
- C和Java中static修饰符的作用
- C语言中restrict关键字
- C/C++ const 修饰符的作用
- C语言中关键字auto、static、register、extern、volatile、restrict的作用
- 多线程中volatile 修饰符的作用
- Java中类修饰符作用域
- PHP中 var 修饰符的作用
- Activity的生命周期和启动模式
- 生活小计一
- 【设计模式】之装饰器模式-PHP
- Http原理实践 Go实现
- 常用的七种数据挖掘的方法
- C++中restrict修饰符作用
- ArrayList的遍历 四种方法
- java数据结构排序之冒泡实现
- Hibernate关系映射
- 《首看vb.net》
- 通过数据结构达到保存多个数据的目的
- MFC获取文件大小的方法
- virtualbox虚拟机下的C:\Users\当前用户\VirtualBox VMs的文件未找到
- ubuntu下的各种命令及说明