2017-01-08 61 views
1

我無法找到ifdef中用來確定illumos內核的宏的任何信息。我使用__linux來捕獲Linux。Illumos內核預處理器宏

填充器爲stackoverflow語法檢查填充填充填充填充。

回答

2

Illumos的基於內核如SmartOS和使用的OpenIndiana和__sunsometimes suggested檢查都__sun__SVR4

[[email protected] ~]# uname -a 
SunOS mysmartostestzone 5.11 joyent_20170202T033902Z i86pc i386 i86pc Solaris 

[[email protected] ~]# 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 
} 

[[email protected] ~]# cc test.c 

[[email protected] ~]# ./a.out 
sun 
__sun 
__sun && __SVR4