收集因为 误使用保留名字, 而造成的比较难以察觉调试的bug?
时间:2010-06-27
来源:互联网
我感觉好像这种情况不会发生,所以问问大家?
作者: peidright 发布时间: 2010-06-27
作者: starwing83 发布时间: 2010-06-27
作者: 没本 发布时间: 2010-06-27
- __declspec(dllexport) void f(void) {}
- __declspec(dllexport) void _imp__f(void) {}
- >>> cl /LD xxx.c
我不知道许多人是从哪学的坏习惯, 要使用下划线开始的名字, 很酷?
有人用 _Bool,_Complex, _Pragma吗? 恭喜, 别想不改源代码就升级到C99
有人用 _Align, _Thread_local吗? C1x打算也开始使用这些名字了。
作者: OwnWaterloo 发布时间: 2010-06-27
是的,在看libc文档,上面也提到了,许多保留字,都是以_开头。。所以我决定不用。_*, __*开头的的变量。
但是,我还是非常想用四个,或者5个____*的。。。。个给人感觉,下划线,就是某种特殊的代名词,而基本字符集中,
没有其他特别的字母,能比较好的表达“特殊”这个概念。
作者: peidright 发布时间: 2010-06-27
libc是语言的组成部分。
保留的名字有一部分就是给libc用的。
另一部分是给编译器扩展用的。
它们使用这些名字是理所当然, 而且是必须的。
为了避免和用户代码的名字冲突。
4-5个也不行, 因为那也算是以下划线开始。
要特殊么。。。 后缀下划线。。。?
和前缀下划线相比, 不太明显……
当年C语言也没多考虑用户感受……
现在什么C#, python 都是把前缀下划线提供给用户使用……
作者: OwnWaterloo 发布时间: 2010-06-27
In addition, some individual header files reserve names beyond those that they actually
define. You only need to worry about these restrictions if your program includes that
particular header file.
• The header file ‘dirent.h’ reserves names prefixed with ‘d_’.
• The header file ‘fcntl.h’ reserves names prefixed with ‘l_’, ‘F_’, ‘O_’, and ‘S_’.
• The header file ‘grp.h’ reserves names prefixed with ‘gr_’.
• The header file ‘limits.h’ reserves names suffixed with ‘_MAX’.
Chapter 1: Introduction 7
• The header file ‘pwd.h’ reserves names prefixed with ‘pw_’.
• The header file ‘signal.h’ reserves names prefixed with ‘sa_’ and ‘SA_’.
• The header file ‘sys/stat.h’ reserves names prefixed with ‘st_’ and ‘S_’.
• The header file ‘sys/times.h’ reserves names prefixed with ‘tms_’.
• The header file ‘termios.h’ reserves names prefixed with ‘c_’, ‘V’, ‘I’, ‘O’, and ‘TC’;
and names prefixed with ‘B’ followed by a digit.
gnu libc 里面,还有这些。。。,以字母开头的,真是混
作者: peidright 发布时间: 2010-06-27
嗯, 除了下划线, 还保留了其他很多。
这是posix保留的吧?
C语言还保留了 str*, mem* 其他还有一些。
vim的文档里也有写……
作者: OwnWaterloo 发布时间: 2010-06-27
从mon,tue,到sun。
结果在sun的机器上编译就悲剧了。
作者: lenovo 发布时间: 2010-06-27
从mon,tue,到sun。
结果在sun的机器上编译就悲剧了。
lenovo 发表于 2010-06-27 21:49
囧
作者: zhaohongjian000 发布时间: 2010-06-27
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28