1

I can't find any info on what macro to use in an ifdef to determine the illumos kernel. I use __linux to catch Linux.

Filler for stackoverflow grammar check filler filler filler filler.

4

1 回答 1

3

SmartOS 和 OpenIndiana 等基于 Illumos 的内核使用__sun有时建议同时检查__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
于 2017-04-27T19:26:06.997 回答