IF_NAMESIZE 对比 IF_NAMESIZE+1

IF_NAMESIZE vs. IF_NAMESIZE+1

当我使用 IF_NAMESIZE(来自 libc 实现中的 net/if.h)作为数组大小时,我应该按原样使用它还是与 + 1 一起用于 [=17=](null字节)?

char iface[IF_NAMESIZE];

char iface[IF_NAMESIZE + 1];

我看到它在各种开源项目中使用两种方式。

The header shall define the following symbolic constant for the length of a buffer containing an interface name (including the terminating NULL character):

IF_NAMESIZE Interface name length.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html

所以:

char iface[IF_NAMESIZE];

够了