我最近遇到了下面的代码:使用静态数组的初始化恒定结构对象
static const struct gaih gaih[] = {
#if defined __UCLIBC_HAS_IPV6__
{ PF_INET6, gaih_inet },
#endif
{ PF_INET, gaih_inet },
#if 0
{ PF_LOCAL, gaih_local },
#endif
{ PF_UNSPEC, NULL }
};
struct gaih {
int family;
int (*gaih)(const char *name, const struct gaih_service *service,
const struct addrinfo *req, struct addrinfo **pai);
};
int func{
const struct gaih *g = gaih;
}
我理解的常数和静态的含义。 但我能够以这种粗糙的方式破译常量对象的静态初始化背后的逻辑。 请澄清这样做的原因或使用
这是什么语言?如果这是C或C++,则应使用正确的语法。 – NathanOliver
它是用于获取网络中主机地址的C代码 – achoora
这不是合法代码。向我们显示正确的代码。 – Simple