Illumos内核预处理器宏

时间:2017-01-08 18:56:45

标签: smartos

我找不到有关在ifdef中使用哪个宏来确定illumos内核的任何信息。我使用__linux来捕获Linux。

用于stackoverflow语法检查填充填充填充物的填充物。

1 个答案:

答案 0 :(得分:2)

基于Illumos的内核(如SmartOS和OpenIndiana)使用__sunsometimes suggested检查__sun__SVR4

[root@mysmartostestzone ~]# uname -a
SunOS mysmartostestzone 5.11 joyent_20170202T033902Z i86pc i386 i86pc Solaris

[root@mysmartostestzone ~]# cat test.c
#include <stdio.h>

int
main(int argc, char **argv)
{
#ifdef sun
printf("sun\n");
#endif

#ifdef __sun
printf("__sun\n");
#endif

#if defined(__sun) && defined(__SVR4)
printf("__sun && __SVR4\n");
#endif
}

[root@mysmartostestzone ~]# cc test.c

[root@mysmartostestzone ~]# ./a.out
sun
__sun
__sun && __SVR4