2015-09-27 9 views
7

Recentemente ho ricevuto una patch che utilizzava __DARWIN_C_LEVEL. Penso che la persona che lo fornisce usi OS X 10.10.Che cos'è il __DARWIN_C_LEVEL simbolo del preprocessore C?

I sistemi operativi OS 10.9, 10.8 e 10.5 sono testati, ma nessuno di essi sembra definirlo.

10,5:

$ uname -a 
Darwin PowerMac.home.pvt 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; 
root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh 
$ cpp -dM < /dev/null | grep -i darwin 
$ 

10,8:

$ uname -a 
Darwin riemann.home.pvt 12.6.0 Darwin Kernel Version 12.6.0: Wed Mar 18 16:23:48 PDT 2015; 
root:xnu-2050.48.19~1/RELEASE_X86_64 x86_64 
$ cpp -dM </dev/null | grep -i darwin 
$ 

Ci sono un sacco di risultati per esso, ma il suo sia un rip del codice sorgente di Apple o una patch di qualcuno . Confer, "__DARWIN_C_LEVEL" site:opensource.apple.com.

di Apple lo usa in questo modo, ma non è chiaro per me quello che stanno cercando di raggiungere:

#if __DARWIN_C_LEVEL > __DARWIN_C_ANSI 
#define _POSIX_ARG_MAX  4096 
#define _POSIX_CHILD_MAX 25 
... 
#endif 

Qual è __DARWIN_C_LEVEL, e come dovrebbe essere utilizzato?

+1

Questa domanda non dovrebbe essere posta nel sito collegato? – Olaf

+0

forse la differenza tra l'utilizzo di ansi C, o C89 o C99 o C11? –

+1

Guarda le righe 582 di /usr/include/sys/cdefs.h –

risposta

1

In <sys/cdefs.h> troverete:

/* 
* Set a single macro which will always be defined and can be used to determine 
* the appropriate namespace. For POSIX, these values will correspond to 
* _POSIX_C_SOURCE value. Currently there are two additional levels corresponding 
* to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) 
*/ 
#define __DARWIN_C_ANSI   010000L 
#define __DARWIN_C_FULL   900000L 

#if defined(_ANSI_SOURCE) 
#define __DARWIN_C_LEVEL  __DARWIN_C_ANSI 
#elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE) 
#define __DARWIN_C_LEVEL  _POSIX_C_SOURCE 
#else 
#define __DARWIN_C_LEVEL  __DARWIN_C_FULL 
#endif 

Così __DARWIN_C_LEVEL sarà o un valore _POSIX_C_SOURCE valido (che sembrano date come 199808L) o sarà due valori ben al di fuori di tale intervallo 010000L e 900000L connotante, a quanto pare , molto meno positività e molto più positività.

  • Se _ANSI_SOURCE è definito __DARWIN_C_LEVEL sarà 010000L;
  • altrimenti se _POSIX_C_SOURCE è definito, ma _DARWIN_C_SOURCE e _NONSTD_SOURCE non sono, __DARWIN_C_LEVEL sarà qualunque _POSIX_C_SOURCE s valore è;
  • altro __DARWIN_C_LEVEL sarà 900000L.
Problemi correlati