const volatile, register volatile, static volatile in C++
来源:互联网 发布:linux mint 安装kde 编辑:程序博客网 时间:2024/05/14 17:26
来源: http://stackoverflow.com/questions/16259939/const-volatile-register-volatile-static-volatile-in-c
register volatile int T=10;
volatile
qualifier means that the compiler cannot apply optimizations or reorder access to T
, Whileregister
is a hint to the compiler that T
will be heavily used. If address of T
is taken, the hint is simply ignored by the compiler. Note that register
is deprecated but still used.
Practical Usage:
I have never used it never felt the need for it and can't really think of any right now.
const volatile int T=10;
const
qualifier means that the T
cannot be modified through code. If you attempt to do so the compiler will provide a diagnostic. volatile
still means the same as in case 1. The compiler cannot optimize or reorder access to T
.
Practical Usage:
- Accessing shared memory in read-only mode.
- Accessing hardware registers in read-only mode.
static volatile int T=10;
static
storage qualifier gives T
static storage duration (C++11 §3.7) and internal linkage, whilevolatile
still governs the optimization and reordering.
Practical Usage:
- Same as
volatile
except that you need the object to have static storage duration and to be inaccessible from other translation units.
- const volatile, register volatile, static volatile in C++
- auto, static, register, const, volatile
- static const volatile register使用
- register,static,const,volatile,extern
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中auto register static const volatile
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言关键字auto、static、register、const、volatile、extern
- C语言中auto,register,static,const,volatile
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中auto,register,static,const,volatile的区别
- C语言中关键字auto、static、register、const、volatile、ex...
- php json_encode 中文乱码的解决方法
- Oracle中的loop循环的例子
- 《深度探索C++对象模型》--4 Function语意学
- android源码包下载地址
- 完全背包使用一维数组
- const volatile, register volatile, static volatile in C++
- Nutch 笔记(一):Quick Start
- webkit关键代码浏览——HTML解析
- Linux内核kprobe机制
- 适用于 Ubuntu 11.04 的 10 个 AppIndicator
- javascript getElementsByClassName函数
- Building MFC application with /MD[d] (CRT dll version)requir...
- 分享一下CHtmlView指定IE内核版本崩溃问题及解决办法
- C++内存分配方式详解——堆、栈、自由存储区、全局/静态存储区和常量存储区