Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议:代码数据类型关键字使用 #31

Open
xicser opened this issue Jan 9, 2020 · 1 comment
Open

建议:代码数据类型关键字使用 #31

xicser opened this issue Jan 9, 2020 · 1 comment

Comments

@xicser
Copy link

xicser commented Jan 9, 2020

建议代码中不要出现具体的数据类型如char、int、short等等,因为这些具体的类型在不同的编译环境中的长度是不同的,尤其是char,有的编译器默认是无符号的、有的默认是有符号的,这会给移植带来问题。

数据类型一律统一定义、见其名知其意,如可定义:
#define u8 unsigned char
#define s8 signed char
... ...
代码中只用s8、或者u8,这样在移植时,只需要根据不同编译环境重新定义u8、s8即可,否则还要关心数据长度、char是否有符号等问题。

@mojinpan
Copy link

mojinpan commented Mar 4, 2020

还是直接用uint8_t这种C99支持的方式比较好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants