搜索
bottom↓
回复: 1

atmel网站笔记AVR306重新编译出现“警告”疑问?

[复制链接]

出0入0汤圆

发表于 2008-4-25 00:10:33 | 显示全部楼层 |阅读模式
我使用IAR4.20a版本对此笔记中的m128_interrupt.c编译后出现“警告”。原先使用IAR3.20版本没有相关警告。当然警告不会影响功能。但我将全局变量的volatile关键字除去后,警告就消除了,全部编译通过。是不是IAR版本升级了,volatile那种关键字已经是默认了?不必要我们来操心?抑或该如何设置?但我在另一应用程序中编译后也出现类似警告,也应是volatile关键字问题,但我省略此关键字后则编译出错——这就更弄不明白了?要知道这些程序在原先老版本中都是顺利编译通过的……

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2008-4-25 00:41:42 | 显示全部楼层
后在各网站搜索了下,有如下回答:

  'volatile' indicates that the value of a variable can change at any
>time and without the knowledge of the compiler.  When you compare two
>volatiles, both have to be read in order to do the comparison and one
>or the other will be read first.  However, one or both values could
>change after reading the first and before reading the second.  The
>compiler is warning the order in which they are read can have an
>impact upon the results of the comparison and the order is undefined

That makes no sense because the iar compilers don't know restricted
varables and they treat every variable as a volatile variable. Therefore
that warning should arise at every comparison of two variables.
Because the iar compilers  treat every variable as a volatile variable
the source code needs does not need the volatile qualifier. This is the
reason why you have to declare all variables, which are modified by ISRs
or schedules processes, as volatile when you port to other compilers
like gcc/mspgcc.
The ANSI standard says that these two different compiler behaviors are
allowed although they are not compatible.

如果是volatile的问题的话那可能是一行中同时出现了两个以上volatile,编译器不知道先去访问哪个物理对象是你的设计本意.
因为多个变量都要求编译器立马访问物理地址.这种警告不必理会.
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-25 14:16

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表