搜索
bottom↓
回复: 3

请教马老师,CVAVR中bool型变量不能作为函数返回值或形参类型吗?

[复制链接]

出0入0汤圆

发表于 2009-12-9 00:09:37 | 显示全部楼层 |阅读模式
例如:
bool abc(unsigned char a);

int xyz(int i, bool x);
这样的生命编译报错, 改为
unsigned char abc(unsigned char a);
int xyz(int i, unsigned char x);
就可以通过,想不明白,请教一下马老师。
查阅了CVAVR的指南也没有这一限制,不知为何。

出0入0汤圆

发表于 2009-12-9 00:22:51 | 显示全部楼层

(原文件名:Data Types.JPG)

出0入0汤圆

 楼主| 发表于 2009-12-9 00:33:24 | 显示全部楼层
Data Types Previous Top Next  

--------------------------------------------------------------------------------

The following table lists all the data types supported by the CodeVisionAVR C compiler, their range of possible values and their size:
  
Type           Size(Bits)        Range
bit            1                 0 , 1
bool, _Bool    8                 0 , 1  
char           8                 -128 to 127
unsigned char  8                 0 to 255
signed char    8                 -128 to 127
int            16                -32768 to 32767
short int      16                -32768 to 32767
unsigned int   16                0 to 65535
signed int     16                -32768 to 32767
long int       32                -2147483648 to 2147483647
unsigned long int 32            0 to 4294967295
signed long int   32            -2147483648 to 2147483647
float             32            ±1.175e-38 to ±3.402e38
double            32            ±1.175e-38 to ±3.402e38

The bit data type is not allowed as the type of an array element or structure/union member.
If the Project|Configure|C Compiler|Code Generation|char is unsigned option is checked or #pragma uchar+ is used, then char has by default the range 0..255.


二楼的没有bool布尔变量类型? 我这个资料怎么会有布尔型呢? 我的是CVAVR 2.04.4a版本,以前在老版本里还真没用过bool型,这次想用一下,发现问题哦。
(不会贴图,复制了一下,不是表格了 :)

出0入0汤圆

发表于 2009-12-10 08:28:10 | 显示全部楼层
bool是新版本中才支持的,
我用1.25.7a的也没有bool的
应该是bit型不能作为参数,不能作的返回值,不能定义位的数组
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 00:09

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

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