BOOL与bool TRUE与true FALSE与false 区别

本文详细阐述了BOOL与bool两种类型的差异,包括它们的数据类型、长度及取值的不同,并对比了FALSE/TRUE与false/true之间的区别。BOOL为int型且长度不定,通常为4字节;bool为布尔型,只有一个字节,取值为false和true。FALSE/TRUE通过预处理宏定义,用于解决C与C++环境差异。

一 BOOL和bool的区别

1、类型不同

  • BOOL为int型
  • bool为布尔型

2、长度不同

  • bool只有一个字节
  • BOOL长度视实际环境来定,一般可认为是4个字节

3、取值不同

  • bool取值false和true,是0和1的区别
  • BOOL取值FALSE和TRUE,是0和非0的区别

BOOL是微软定义的typedef int BOOL。与bool不同,它是一个三值逻辑,TRUE/FALSE/ERROR,返回值为>0的整数为TRUE,0为FALSE,-1为ERROR。Win32 API中很多返回值为BOOL的函数都是三值逻辑。比如GetMessage().

二 FALSE/TRUE与false/true的区别

false/true是标准C++语言里新增的关键字,而FALSE/TRUE是通过#define,这要用途

是解决程序在C与C++中环境的差异,以下是FALSE/TRUE在windef.h的定义:

#ifndef FALSE

#define FALSE 0

#endif

#ifndef TRUE

#define TRUE 1

#endif

 

 

name type offset Auto/Manual_Mode Bool 0 FALSE FALSE TRUE TRUE TRUE FALSE 切换为手动调试模式 Axis_X_Ready Bool 0.1 FALSE FALSE TRUE TRUE TRUE FALSE X轴伺服准备就绪 Axis_Y_Ready Bool 0.2 FALSE FALSE TRUE TRUE TRUE FALSE Y轴伺服准备就绪 Axis_Z_Ready Bool 0.3 FALSE FALSE TRUE TRUE TRUE FALSE Z轴伺服准备就绪 Axis_X_InPosition Bool 0.4 FALSE FALSE TRUE TRUE TRUE FALSE X轴到达目标位置 Axis_Y_InPosition Bool 0.5 FALSE FALSE TRUE TRUE TRUE FALSE Y轴到达目标位置 Axis_Z_InPosition Bool 0.6 FALSE FALSE TRUE TRUE TRUE FALSE Z轴到达目标位 Emergency_Active Bool 0.7 FALSE FALSE TRUE TRUE TRUE FALSE 急停状态激活(需复位) Safety_Door_Open Bool 1 FALSE FALSE TRUE TRUE TRUE FALSE 安全门未关闭(触发停机) Servo_Alarm Int 2 0 FALSE TRUE TRUE TRUE FALSE 伺服报警代码(0=正常) PLC_Error_Code Int 4 0 FALSE TRUE TRUE TRUE FALSE PLC错误代码(0=正常) Actual_Pos_X1 Real 6 0 FALSE TRUE TRUE TRUE FALSE X1运行数据 Actual_Pos_Y1 Real 10 0 FALSE TRUE TRUE TRUE FALSE Y1运行数据 Actual_Pos_Z1 Real 14 0 FALSE TRUE TRUE TRUE FALSE Z1运行数据 Actual_Pos_X_2 Real 18 0 FALSE TRUE TRUE TRUE FALSE X2运行数据 Actual_Pos_Y_2 Real 22 0 FALSE TRUE TRUE TRUE FALSE Y2运行数据 Actual_Pos_Z_2 Real 26 0 FALSE TRUE TRUE TRUE FALSE Z2运行数据 Actual_ActVelocity_X1 Int 30 0 FALSE TRUE TRUE TRUE FALSE X1运行速度 Actual_ActVelocity_Y1 Int 32 0 FALSE TRUE TRUE TRUE FALSE Y1运行速度 Actual_ActVelocity_Z1 Int 34 0 FALSE TRUE TRUE TRUE FALSE Z1运行速度 Actual_ActVelocity_X2 Int 36 0 FALSE TRUE TRUE TRUE FALSE X2运行速度 Actual_ActVelocity_Y2 Int 38 0 FALSE TRUE TRUE TRUE FALSE Y2运行速度 Actual_ActVelocity_Z2 Int 40 0 FALSE TRUE TRUE TRUE FALSE Z2运行速度 X1_ executes_ the_ movement Bool 42 FALSE FALSE TRUE TRUE TRUE FALSE X1执行运动 Y1_ executes_ the_ movement Bool 42.1 FALSE FALSE TRUE TRUE TRUE FALSE Y1执行运动 Z1_ executes_ the_ movement Bool 42.2 FALSE FALSE TRUE TRUE TRUE FALSE Z1执行运动 X2_ executes_ the_ movement Bool 42.3 FALSE FALSE TRUE TRUE TRUE FALSE X2执行运动 Y2_ executes_ the_ movement Bool 42.4 FALSE FALSE TRUE TRUE TRUE FALSE Y2执行运动 Z2_ executes_ the_ movement Bool 42.5 FALSE FALSE TRUE TRUE TRUE FALSE Z2执行运动 X1_completed Bool 42.6 FALSE FALSE TRUE TRUE TRUE FALSE X1执行完毕 Y1_completed Bool 42.7 FALSE FALSE TRUE TRUE TRUE FALSE Y1执行完毕 Z1_completed Bool 43 FALSE FALSE TRUE TRUE TRUE FALSE Z1执行完毕 X2_completed Bool 43.1 FALSE FALSE TRUE TRUE TRUE FALSE X2执行完毕 Y2_completed Bool 43.2 FALSE FALSE TRUE TRUE TRUE FALSE Y2执行完毕 Z2_completed Bool 43.3 FALSE FALSE TRUE TRUE TRUE FALSE Z2执行完毕 X1_axis_error Bool 43.4 FALSE FALSE TRUE TRUE TRUE FALSE X1轴报错 Y1_axis_error Bool 43.5 FALSE FALSE TRUE TRUE TRUE FALSE Y1轴报错 Z1_axis_error Bool 43.6 FALSE FALSE TRUE TRUE TRUE FALSE Z1轴报错 X2_axis_error Bool 43.7 FALSE FALSE TRUE TRUE TRUE FALSE X2轴报错 Y2_axis_error Bool 44 FALSE FALSE TRUE TRUE TRUE FALSE Y2轴报错 Z2_axis_error Bool 44.1 FALSE FALSE TRUE TRUE TRUE FALSE Z2轴报错 Emergency stop Real 46 0 FALSE TRUE TRUE TRUE FALSE 急停 Servo zeroing is complete Real 50 0 FALSE TRUE TRUE TRUE FALSE 伺服归零完成 Servo zeroing Real 54 0 FALSE TRUE TRUE FALSE FALSE 伺服归零中 Left start Bool 58 FALSE FALSE TRUE TRUE TRUE FALSE 左启动 Left reset Bool 58.1 FALSE FALSE TRUE TRUE TRUE FALSE 左复位 Left replay Bool 58.2 FALSE FALSE TRUE TRUE TRUE FALSE 左重打 Left screw detection Bool 58.3 FALSE FALSE TRUE TRUE TRUE FALSE 左螺钉检测 The cylinder attached to the left is in situ Bool 58.4 FALSE FALSE TRUE TRUE TRUE FALSE 左所附气缸原位 Left lock payment begins Bool 58.5 FALSE FALSE TRUE TRUE TRUE FALSE 左 锁付开始 Left lock in the middle Bool 58.6 FALSE FALSE TRUE TRUE TRUE FALSE 左锁付中 Left lock pay OK Bool 58.7 FALSE FALSE TRUE TRUE TRUE FALSE 左 锁付OK The left lock is attached to the NG Bool 59 FALSE FALSE TRUE TRUE TRUE FALSE 左锁附NG Left camera triggers Bool 59.1 FALSE FALSE TRUE TRUE TRUE FALSE 左相机触发 Left positioning calibration Bool 59.2 FALSE FALSE TRUE TRUE TRUE FALSE 左定位校准 Left camera detection is OK Bool 59.3 FALSE FALSE TRUE TRUE TRUE FALSE 左相机检测OK The left camera detects NG Bool 59.4 FALSE FALSE TRUE TRUE TRUE FALSE 左相机检测NG Left cylinder 1 single control Bool 59.5 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸1 单控 Left cylinder 2 single control Bool 59.6 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸2单控 Left cylinder 3 single control_1 Bool 59.7 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸3单控 Left cylinder4 single control_2 Bool 60 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸4单控 Left cylinder signal 1 Bool 60.1 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号1 Left cylinder signal 2 Bool 60.2 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号2 Left cylinder signal 3 Bool 60.3 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号3 Left cylinder signal 4 Bool 60.4 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号4 Left cylinder signal 5 Bool 60.5 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号5 Left cylinder signal 6 Bool 60.6 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号6 Left cylinder signal 7 Bool 60.7 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号7 Left cylinder signal 8 Bool 61 FALSE FALSE TRUE TRUE TRUE FALSE 左气缸信号8 Start right Bool 61.1 FALSE FALSE TRUE TRUE TRUE FALSE 右启动 Right reset Bool 61.2 FALSE FALSE TRUE TRUE TRUE FALSE 右复位 Right replay Bool 61.3 FALSE FALSE TRUE TRUE TRUE FALSE 右重打 Right screw detection Bool 61.4 FALSE FALSE TRUE TRUE TRUE FALSE 右螺钉检测 The right attached cylinder is in situ Bool 61.5 FALSE FALSE TRUE TRUE TRUE FALSE 右所附气缸原位 Right lock payment starts Bool 61.6 FALSE FALSE TRUE TRUE TRUE FALSE 右 锁付开始 The right lock is in the middle Bool 61.7 FALSE FALSE TRUE TRUE TRUE FALSE 右锁付中 Right lock pay OK Bool 62 FALSE FALSE TRUE TRUE TRUE FALSE 右锁付OK The right lock is attached to the NG Bool 62.1 FALSE FALSE TRUE TRUE TRUE FALSE 右锁附NG Right camera triggers Bool 62.2 FALSE FALSE TRUE TRUE TRUE FALSE 右相机触发 Right positioning calibration Bool 62.3 FALSE FALSE TRUE TRUE TRUE FALSE 右定位校准 Right camera detection OK Bool 62.4 FALSE FALSE TRUE TRUE TRUE FALSE 右相机检测OK The right camera detects NG Bool 62.5 FALSE FALSE TRUE TRUE TRUE FALSE 右相机检测NG Right cylinder 1 single control Bool 62.6 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸1 单控 Right cylinder 2 single control Bool 62.7 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸2单控 Right cylinder 3 single control_1 Bool 63 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸3单控 Right cylinder 2 single controlRight cylinder 4 single control Bool 63.1 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸4单控 Right cylinder signal 1 Bool 63.2 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号1 Right cylinder signal 2 Bool 63.3 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号2 Right cylinder signal 3 Bool 63.4 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号3 Right cylinder signal 4 Bool 63.5 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号4 Right cylinder signal 5 Bool 63.6 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号5 Right cylinder signal 6 Bool 63.7 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号6 Right cylinder signal 7 Bool 64 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号7 Right cylinder signal 8 Bool 64.1 FALSE FALSE TRUE TRUE TRUE FALSE 右气缸信号8 重新更新config.py文件
06-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

量子象限

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值