- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我知道 volatile
变量背后的概念。基本上,对该变量的所有读取和写入操作都必须 发生。有没有一种方法可以让优化器仅执行所有写入并假设读取将始终保持不变(除非通过写入进行修改)。
另外(沿着同一行)有一种方法可以为编译器定义一种新的内存类型来存储变量。例如,如果我有一个带 SD 卡的微 Controller ,我能否将 SD 卡定义为存储内存的地方(或者我是否明确必须自己完成所有读/写操作)。
郑重声明,我使用 gcc 作为我的编译器,如果有任何我可以专门(且仅)在 gcc 上做的事情的话
最佳答案
I know the concept behind volatile variables.
好的...
Basically all reads and writes to that variable must occur.
绝对不是“基本上”。
Is there a way to allow the optimizer to get away with only doing all of the writes and assuming that the reads will always stay the same (unless modified by writing).
没有
<- 剪断 ->
volatile 用于模拟对内存映射 I/O 的读/写访问。 “写入”此类 I/O 通常会触发电子设备中的事件,即使写入的值与之前写入的值相同。
volatile 没有其他用途 - 不,甚至在多线程中也没有(无论如何它都不会做你想做的事)。
来自§7.1.6.1
[ Note: volatile is a hint to the implementation to avoid aggressive optimization involving the object because the value of the object might be changed by means undetectable by an implementation. Furthermore, for some implementations, volatile might indicate that special hardware instructions are required to access the object. See 1.9 for detailed semantics. In general, the semantics of volatile are intended to be the same in C++ as they are in C. — end note ]
这里的含义是,除非您确切了解实现对 volatile 变量的作用,否则您没有地方可以使用它。
它的使用是不可移植的,所以如果使用的话,应该包含在您正在处理的任何概念的特定于实现的特化中。
关于c++ - 给优化器更大的 "License",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36657121/
我正在 Java 上开发 Tic Tac Toe 游戏(eclipse)。在我的计算机上,我的对话框非常小。我一直在努力把它做得更大。我没有任何运气。我希望这里有人能引导我走向正确的方向。下面的代码是
出于辅助功能的目的,我需要使所有可滚动控件(列表、 ListView )的滚动条更宽,滚动条箭头更大。 如何从可滚动控件(例如:TListView)获取滚动条( handle )? 如何使滚动条和箭头
在我的 flutter 应用程序中,我想制作一个圆圈作为这样的背景: 最佳答案 问题主要是当屏幕处于横向时,除非它覆盖整个屏幕,否则你不能在那里放置一个圆圈。 ClipRect 还有另一种方法,如果这
如何在列表中找到最接近的值,这将返回更高的值?示例:[3,7,12,19] 的列表,如果我的值为 8,我如何获得最接近(更大)的值 12?我想要 dart 中的这个逻辑。 最佳答案 只需过滤 List
我是一个绝对的 HTML 和 javascript 初学者,我很确定,这真的很容易实现。我生成了以下 IFRAME: document.write("");Das aktuelle Wetter in
我有点知道为什么压缩 DES 文件时它更大,但谁能给我正确的理由或链接,我似乎找不到任何原因? 谢谢:) 最佳答案 经过适当加密的密文在压缩程序看来非常像一系列随机数。如果没有以明文形式出现的模式,压
假设我有两个表,其中一个(我们称之为 person)有一个名为 type 的字段,该字段存储链接到另一个表的整数(我们称之为types 带有一个名为 id 的字段。什么会更能提高性能? 一个更大的查询
我有一个ListView,它使用GridView来显示DataTable,并且当新行添加到DataTable
我在只出现在 Firefox 中的导航菜单上遇到了一个奇怪的问题(在 IE7、8、9、10 和 Chrome 中工作正常)。菜单上的链接显示为 block ,但它们在 Firefox 中计算得比任何其
我正在使用 javax.mail 并获取邮件收件箱文件夹中的邮件计数。使用https://outlook.office.com/ Folder folderInbox = store.getFolde
我想让地球字形图标更大,以便它覆盖页面的大部分(它是矢量图像)。它不在按钮或任何东西中;它只是一个人。有没有办法做到这一点? 最佳答案 增加 glyphicon 的 font-size
我定制了一个看起来像这样的搜索栏 问题是很难捕获 slider 。所以我想做的是增加拇指的碰撞箱以使其更容易。我尝试了一些东西,但总是弄乱了搜索栏的外观。我有什么想法可以做到这一点吗? 布局.xml
我有一个问题:下载到 Documents 文件夹中的音乐比以前长 2 倍,而且体积更大。比特率也有问题(增加/减少 2 倍)。图片保存得很好,但任何音乐都有问题。也许我需要手动设置音频比特率,但我还没
为什么 div 区域仍然比图像 css 大? /image/WHDU3.jpg 如何设置 div 区域以适合图像? 最佳答案 IMG - 是行内元素,因此
我发现在对文本文件进行排序时非常困惑。不同的算法/应用程序会产生不同的结果,例如,比较两个字符串 str1=";P" 和 str2="-_-" 仅供引用,这里给出了这些字符串中每个字符的 ASCII:
我有一个应用程序已经在 Play 商店中存在多年,我刚刚构建了一个更新。该更新利用了 numberpicker,它的 min-sdk 为 11,并且在 v4 支持库中不适用。我倾向于发布我的新版本并在
你能告诉我如何强制 CSS 使 line-through 属性比元素 width 宽吗? 例如 50 结果看起来像现在如何使线条比元素更宽更明显? 赞 最佳答案 你可以使用 ,这是一种很俗气的方式 &
我想制作一个比应有的大得多的虚拟 Win32 EXE 文件。所以默认情况下,样板 Win32 EXE 文件为 80 KB。我想要一个 5 MB 的空间来测试其他一些实用程序。 第一个想法是添加资源,但
我有一个 UIView,里面有一个更大的 UIImageView。有没有办法隐藏超出 View 大小的内容? CGRect baseFrame = CGRectMake(100, 100, 300,
当我改变缓冲区的大小时,我得到了无法从 BufferedReader 解释的奇怪结果。 我曾强烈期望性能会随着缓冲区大小的增加而逐渐增加, yield 递减设置相当快,此后性能或多或少会持平。但看起来
我是一名优秀的程序员,十分优秀!