“Status” vs. “state”

本文探讨了英语中“status”与“state”的区别,并通过具体例子解释了二者在描述项目进展及对象状况时的不同用法。

http://english.stackexchange.com/questions/12958/status-vs-state

 

Can anyone explain what the difference between status and state is when I talk about the condition or situation of an object?

Here's what I got from Longman English Dictionary.

status: a situation at a particular time, especially in an argument, discussion etc.

state: the physical or mental condition that someone or something is in

For example, how do you interpret these two sentences:

  1. What is the current status of this project?

  2. What is the current state of this project?

`enumerated type mixed with another type` 报错通常是因为在代码中将枚举类型其他类型进行了不恰当的混合使用。在给出的代码片段 `void device_status_clean() { device_status.latest_error = 0x0000; device_status.state = STATE_NO_ERROR; //TODO:减少还是重置当前错误计数器?}` 中,可能是 `device_status.state` 是枚举类型,而赋值操作存在类型不匹配的问题。 假设 `STATE_NO_ERROR` 是一个枚举常量,而 `device_status.state` 也是枚举类型,那么赋值操作本身应该是合法的。但如果 `device_status.state` 的类型 `STATE_NO_ERROR` 不匹配,就会出现这个错误。 以下是几种可能的解决办法: #### 1. 检查枚举类型定义 确保 `STATE_NO_ERROR` 所属的枚举类型 `device_status.state` 的类型一致。例如: ```c // 定义枚举类型 typedef enum { STATE_ERROR, STATE_NO_ERROR } DeviceState; // 定义设备状态结构体 typedef struct { uint16_t latest_error; DeviceState state; } DeviceStatus; DeviceStatus device_status; // 清理函数 void device_status_clean() { device_status.latest_error = 0x0000; device_status.state = STATE_NO_ERROR; //TODO:减少还是重置当前错误计数器? } ``` #### 2. 进行类型转换 如果确实需要将不同类型的值赋给 `device_status.state`,可以进行显式的类型转换。但这种方法要谨慎使用,因为可能会导致未定义行为。 ```c // 假设 STATE_NO_ERROR 是一个整数常量 #define STATE_NO_ERROR 1 // 定义枚举类型 typedef enum { STATE_ERROR, STATE_OK } DeviceState; // 定义设备状态结构体 typedef struct { uint16_t latest_error; DeviceState state; } DeviceStatus; DeviceStatus device_status; // 清理函数 void device_status_clean() { device_status.latest_error = 0x0000; device_status.state = (DeviceState)STATE_NO_ERROR; //TODO:减少还是重置当前错误计数器? } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值