2

今天我遇到了麻烦 - android的ndk没有SUN_LEN宏(sys/un.h || linux/un.h),我不想修补android的头文件,怎么办更好?

4

2 回答 2

4

不要修补标题,在您自己的文件中定义它。

#ifndef SUN_LEN //In case they fix it down the road
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen((ptr)->sun_path))
#endif
于 2012-09-27T19:09:27.557 回答
0

SUN_LEN 宏是不可移植的(也不是 POSIX 标准的一部分)扩展。
使用它是完全安全的sizeof(struct sockaddr_un)

于 2016-10-27T14:31:44.147 回答