<分区>
我正在阅读 K&R 书。我阅读:
...name intended for use only by functions of the standard library begin with
_
so they are less likely to collide with the names in the user program...
这到底是什么意思,请解释真正简单实用的方法。
我的理解是:
如果我想使用 math.h 中定义的 sqrt 则
#include <math.h>
#define sqrt(x) x*x*x
main()
{
int x=4;
_sqrt(x); // That is from the header file math.h
sqrt(x); // my own defined macro
/*or its the reverse way _sqrt for my own defined macro so it won't collide with original sqrt i.e. without _ for sqrt from math.h */
return 0;
}
现在,我使用 __
在 stackoverflow 上阅读了一段代码。 sys/syscall.h 在 Windows 中不存在,所以我们必须使用
#if __linux
#include <sys/syscall.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
__
到底用在什么地方,__
和 _
有什么区别。