变量声明类型定义 C 中的约定
Variable Declaration typedefs conventions in C
自从我开始用 C 编程以来,我知道/看到每个人都在使用 typedefs 声明变量时使用以下约定,如下所示:
int32_t *data_value;
const int16_t *Order_Of_Mag;
uint16_t min_change;
uint8_t eeprom_save_flag;
我知道部分原因是不同架构之间的可移植性。有谁知道何时和/或什么标准规定了这种声明方法?
另外,处理需要使用 char 的标准库 (stdio.h) 函数的推荐方法是什么,因为 char 既不uint8_t也不int8_t(请参阅下面的示例函数)
sscanf(const char *format)
int atio(const char *s)
提前致谢
据我所知,唯一需要你使用这种typedef的标准是项目/公司特定的编码约定。然后,这些编码约定还准确指定要使用的 typedefs(甚至宏),因此可能会UINT32
而不是必须使用的uint32_t
至于在char
、uint8_t
或int8_t
之间进行选择,默认应该是使用char
来表示字符数据(即字符串和字符),而uint8_t
或int8_t
用于小数字。
相关文章:
- 在提升multi_index容器中,是否定义了"default index"?
- #定义c-预处理器常量..我做错了什么
- 用C++中的一个变量定义一个常量
- 部分定义/别名模板模板参数
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- #为""定义宏;静态";针对不同的上下文
- 如何确保C++函数在定义之前声明(如override关键字)
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 当类在C++中定义时,有什么方法可以"register"类吗?
- 在命名空间中定义函数还是限定函数
- 此代码是否违反一个定义规则
- 编译C++时未定义的引用
- 不同翻译单元中不可重载的非内联函数定义
- 变量声明类型定义 C 中的约定
- 为C++结构定义显式析构函数如何影响调用约定
- 定义呼叫约定有什么意义
- 关于类定义的C++编程约定
- 在类中定义二进制运算符的风格指南/约定(c++)
- c++自定义调用约定
- c++调用约定是否受标准约束,因为在声明fn时不需要定义函数的返回类型