何时应该使用以下陈述之一?
typedef struct Foo {
int a;
} Bar;
Run Code Online (Sandbox Code Playgroud)
和
typedef struct {
int a;
} Bar;
Run Code Online (Sandbox Code Playgroud)
并使用它
Bar bar1 = { 5 };
Run Code Online (Sandbox Code Playgroud)
我理解第二个是匿名结构但不确定何时应该使用另一个结构.
我正在读K&R书.我读:
...仅供标准库函数使用的名称,
_因此它们不太可能与用户程序中的名称冲突...
这究竟意味着什么,请解释真实简单实用的方法.
我的理解是:
如果我想使用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;
}
Run Code Online (Sandbox Code Playgroud)
现在,我使用了在stackoverflow上读取代码__.sys/syscall.h在Windows中不存在,所以我们必须使用
#if __linux
#include <sys/syscall.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
Run Code Online (Sandbox Code Playgroud)
确切__使用的地方和b/w __&的区别_ …
c ×2