IdCompilerDefines.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. {$IFDEF CONDITIONALEXPRESSIONS}
  2. // Must be at the top...
  3. {$IF CompilerVersion >= 24.0}
  4. {$LEGACYIFEND ON}
  5. {$IFEND}
  6. {$ENDIF}
  7. // General
  8. // S.G. 4/9/2002: IPv4/IPv6 general switch (for defaults only)
  9. {$DEFINE IdIPv4} // use IPv4 by default
  10. {.$IFDEF IdIPv6} // use IPv6 by default
  11. {$DEFINE INDY110}
  12. {$DEFINE 11_0_0} //so developers can IFDEF for this specific version
  13. {$UNDEF USE_OPENSSL}
  14. {$UNDEF STATICLOAD_OPENSSL}
  15. {$UNDEF USE_ZLIB_UNIT}
  16. {$UNDEF USE_SSPI}
  17. // $DEFINE the following if the global objects in the IdStack and IdThread
  18. // units should be freed on finalization
  19. // TODO: can this be enabled by default now?
  20. {.$DEFINE FREE_ON_FINAL}
  21. {$UNDEF FREE_ON_FINAL}
  22. // Make sure the following is $DEFINE'd only for suitable environments
  23. // as specified further below. This works in conjunction with the
  24. // FREE_ON_FINAL define above.
  25. {$UNDEF REGISTER_EXPECTED_MEMORY_LEAK}
  26. {$UNDEF HAS_System_RegisterExpectedMemoryLeak}
  27. // FastMM is natively available in BDS 2006 and higher. $DEFINE the
  28. // following if FastMM has been installed manually in earlier versions
  29. {.$DEFINE USE_FASTMM4}
  30. {$UNDEF USE_FASTMM4}
  31. // $DEFINE the following if MadExcept has been installed manually in
  32. // BDS 2005 or earlier (System.RegisterExpectedMemoryLeak() was introduced
  33. // in BDS 2006)
  34. {.$DEFINE USE_MADEXCEPT}
  35. {$UNDEF USE_MADEXCEPT}
  36. // $DEFINE the following if LeakCheck has been installed manually in
  37. // BDS 2005 or earlier (System.RegisterExpectedMemoryLeak() was introduced
  38. // in BDS 2006)
  39. {.$DEFINE USE_LEAKCHECK}
  40. {$UNDEF USE_LEAKCHECK}
  41. // Make sure the following are $DEFINE'd only for Delphi/C++Builder 2009 onwards
  42. // as specified further below. The VCL is fully Unicode, where the 'String'
  43. // type maps to System.UnicodeString, not System.AnsiString anymore
  44. {$UNDEF STRING_UNICODE_MISMATCH}
  45. // Make sure the following are $DEFINE'd only for suitable environments
  46. // as specified further below. Delphi/C++Builder Mobile/NextGen compilers
  47. // do not support Ansi data types anymore, and is moving away from raw
  48. // pointers as well.
  49. //
  50. // UPDATE: in Delphi/C++Builder 10.4, all Ansi types are supported again on
  51. // all platforms, including the mobile compilers.
  52. {$DEFINE HAS_AnsiString}
  53. {$DEFINE HAS_AnsiChar}
  54. {$DEFINE HAS_PAnsiChar}
  55. {$UNDEF HAS_PPAnsiChar}
  56. {$UNDEF NO_ANSI_TYPES}
  57. // Make sure the following are $DEFINE'd only for suitable environments
  58. // as specified further below. Delphi/C++Builder Mobile/NextGen compilers
  59. // use ARC for TObject life time management.
  60. //
  61. // UPDATE: ARC for TObject lifetime management has been removed in
  62. // Delphi/C++Builder 10.4 mobile compilers. All platforms now use a single
  63. // unified memory management model!
  64. {$UNDEF USE_MARSHALLED_PTRS}
  65. {$UNDEF HAS_MarshaledAString}
  66. {$UNDEF USE_OBJECT_ARC}
  67. {$UNDEF HAS_UNSAFE_OBJECT_REF}
  68. {$UNDEF HAS_WEAK_OBJECT_REF}
  69. {$UNDEF USE_OBJECT_REF_FREENOTIF}
  70. // Make sure the following is $DEFINE'd only for suitable environments
  71. // as specified further below.
  72. {$UNDEF STRING_IS_IMMUTABLE}
  73. // Make sure the following are $DEFINE'd only for suitable environments
  74. // as specified further below.
  75. {$UNDEF HAS_TEncoding}
  76. {$UNDEF HAS_TEncoding_GetEncoding_ByEncodingName}
  77. {$UNDEF HAS_TEncoding_EncodingName}
  78. {$UNDEF HAS_TEncoding_CodePage}
  79. {$UNDEF HAS_Exception_RaiseOuterException}
  80. {$UNDEF HAS_System_ReturnAddress}
  81. {$UNDEF HAS_TCharacter}
  82. {$UNDEF HAS_TInterlocked}
  83. {$UNDEF HAS_TNetEncoding}
  84. // Make sure that this is defined only for environments where we are using
  85. // the iconv library to charactor conversions.
  86. {.$UNDEF USE_ICONV}
  87. {.$UNDEF USE_LCONVENC}
  88. //Define for Delphi cross-compiler targetting Posix
  89. {$UNDEF USE_VCL_POSIX}
  90. {$UNDEF HAS_ComponentPlatformsAttribute}
  91. {$UNDEF HAS_DIRECTIVE_WARN_DEFAULT}
  92. // Define for Delphi to auto-generate platform-appropriate '#pragma link' statements in HPP files
  93. {$UNDEF HAS_DIRECTIVE_HPPEMIT_LINKUNIT}
  94. // detect compiler versions and features
  95. {$IFDEF FPC}
  96. {$I IdCompilerDefines_FPC.inc}
  97. {$ELSE}
  98. // DCC is not defined by Delphi until XE2. Check for earlier compiler
  99. // versions and define DCC manually if detected...
  100. {$I IdCompilerDetectDCC.inc}
  101. {$IFDEF DCC}
  102. {$I IdCompilerDefines_DCC.inc}
  103. {$ELSE}
  104. {$MESSAGE FATAL 'Unknown compiler!'}
  105. {$ENDIF}
  106. {$ENDIF}
  107. {$IF (NOT DEFINED(USE_OBJECT_ARC)) OR DEFINED(HAS_UNSAFE_OBJECT_REF)}
  108. {$DEFINE USE_OBJECT_REF_FREENOTIF}
  109. {$IFEND}
  110. {$IFNDEF UNICODE}
  111. {$DEFINE STRING_UNICODE_MISMATCH}
  112. {$ENDIF}
  113. {$IF DEFINED(WIN32) OR DEFINED(WIN64)}
  114. {$DEFINE WIN32_OR_WIN64}
  115. {$DEFINE USE_ZLIB_UNIT}
  116. {$IFNDEF DCC_NEXTGEN}
  117. {$DEFINE USE_OPENSSL} // !!!·MOVED·HERE·BY·EMBT
  118. {$DEFINE USE_SSPI}
  119. {$DEFINE SSPI_UNICODE}
  120. {$ENDIF}
  121. {$ELSEIF DEFINED(WINCE)}
  122. {$DEFINE USE_OPENSSL}
  123. // RLebeau: not sure if the above Win32/64 defines also apply to WinCE,
  124. // so keeping them separate for now...
  125. {$IFEND}
  126. // High-performance counters are not reliable on multi-core systems, and have
  127. // been known to cause problems with TIdIOHandler.ReadLn() timeouts in Windows
  128. // XP SP3, both 32-bit and 64-bit. Refer to these discussions for more info:
  129. //
  130. // http://www.virtualdub.org/blog/pivot/entry.php?id=106
  131. // http://blogs.msdn.com/oldnewthing/archive/2008/09/08/8931563.aspx
  132. //
  133. // Do not enable thus unless you know it will work correctly on your systems!
  134. {$IFDEF WINDOWS}
  135. {.$DEFINE USE_HI_PERF_COUNTER_FOR_TICKS}
  136. {$ENDIF}
  137. {$IFDEF UNIX}
  138. {$DEFINE USE_OPENSSL}
  139. {$DEFINE USE_ZLIB_UNIT}
  140. {$ENDIF}
  141. {$IF (DEFINED(UNIX)
  142. OR DEFINED(MACOS)
  143. OR DEFINED(DARWIN)
  144. OR DEFINED(LINUX)
  145. OR DEFINED(IOS)
  146. OR DEFINED(FREEBSD))
  147. AND (NOT DEFINED(ANDROID))}
  148. {$DEFINE HAS_getifaddrs}
  149. {$IFEND}
  150. {$IFDEF IOS}
  151. {$DEFINE USE_OPENSSL}
  152. // Support for 64-bit ARM iOS Simulator was added in Delphi 11.2
  153. // TODO: how to detect iOS Simulator in FPC? Does it support 64-bit ARM?
  154. {$IF DEFINED(CPUARM) AND (NOT DEFINED(IOSSIMULATOR))}
  155. // RLebeau: For iOS devices, OpenSSL cannot be used as an external library,
  156. // it must be statically linked into the app. For the iOS simulator, this
  157. // is not true. Users who want to use OpenSSL in iOS device apps will need
  158. // to add the static OpenSSL library to the project and then include the
  159. // IdSSLOpenSSLHeaders_static unit in their uses clause. It hooks up the
  160. // statically linked functions for the IdSSLOpenSSLHeaders unit to use...
  161. {$DEFINE STATICLOAD_OPENSSL}
  162. {$IFEND}
  163. {$ENDIF}
  164. //
  165. //iconv defines section.
  166. {$DEFINE USE_ICONV_UNIT}
  167. {$DEFINE USE_ICONV_ENC}
  168. {$IFDEF UNIX}
  169. {$DEFINE USE_ICONV}
  170. {$IF DEFINED(USE_BASEUNIX)}
  171. {$IFDEF FPC}
  172. {$UNDEF USE_ICONV_UNIT}
  173. {$ELSE}
  174. {$UNDEF USE_ICONV_ENC}
  175. {$ENDIF}
  176. {$ELSEIF DEFINED(KYLIXCOMPAT)}
  177. //important!! Iconv functions are defined in the libc.pas Kylix compatible unit.
  178. {$UNDEF USE_ICONV_ENC}
  179. {$UNDEF USE_ICONV_UNIT}
  180. {$IFEND}
  181. {$ENDIF}
  182. {$IFDEF NETWARELIBC}
  183. {$DEFINE USE_ICONV}
  184. //important!!! iconv functions are defined in the libc.pas Novell Netware header.
  185. //Do not define USE_ICONV_UNIT
  186. {$UNDEF USE_ICONV_UNIT}
  187. {$UNDEF USE_ICONV_ENC}
  188. {$ENDIF}
  189. {$UNDEF USE_INVALIDATE_MOD_CACHE}
  190. {$UNDEF USE_SAFELOADLIBRARY}
  191. {$IFDEF WINDOWS}
  192. {$UNDEF USE_ICONV_ENC}
  193. {$DEFINE USE_SAFELOADLIBRARY}
  194. {$ENDIF}
  195. // Use here for all *nix systems that you do not want to use iconv library
  196. {$IF DEFINED(FPC) AND DEFINED(ANDROID)}
  197. {$UNDEF USE_ICONV}
  198. {$DEFINE USE_LCONVENC}
  199. {$IFEND}
  200. //This must come after the iconv defines because this compiler targets a Unix-like
  201. //operating system. One key difference is that it does have a TEncoding class.
  202. //If this comes before the ICONV defines, it creates problems.
  203. //This also must go before the THandle size calculations.
  204. {$IFDEF DCC_CROSS_COMPILE}
  205. {$IFDEF POSIX}
  206. {$IFNDEF LINUX}
  207. {$DEFINE BSD}
  208. {$ENDIF}
  209. {$DEFINE USE_SAFELOADLIBRARY}
  210. {$DEFINE USE_INVALIDATE_MOD_CACHE}
  211. {$ENDIF}
  212. //important!!! iconv functions are defined in the libc.pas Novell Netware header.
  213. //Do not define USE_ICONVUNIT
  214. {$UNDEF USE_ICONV}
  215. {$UNDEF USE_ICONV_UNIT}
  216. {$UNDEF USE_ICONV_ENC}
  217. {$DEFINE INT_THREAD_PRIORITY}
  218. {$ENDIF}
  219. {$IFNDEF USE_ICONV}
  220. {$UNDEF USE_ICONV_UNIT}
  221. {$UNDEF USE_ICONV_ENC}
  222. {$ENDIF}
  223. {
  224. BSD 4.4 introduced a minor API change. sa_family was changed from a 16bit
  225. word to an 8 bit byte and an 8 bit byte field named sa_len was added.
  226. }
  227. //Place this only after DARWIN has been defined for Delphi MACOS
  228. {$IF DEFINED(FREEBSD)
  229. OR DEFINED(DARWIN)
  230. OR DEFINED(HAIKU)
  231. OR DEFINED(MORPHOS)}
  232. {$DEFINE SOCK_HAS_SINLEN}
  233. {$IFEND}
  234. // Do NOT remove these IFDEF's. They are here because InterlockedExchange
  235. // only handles 32bit values. Some Operating Systems may have 64bit
  236. // THandles. This is not always tied to the platform architecture.
  237. {$IF DEFINED(AMIGA)
  238. OR DEFINED(EMBEDDED)
  239. OR DEFINED(MACOS_CLASSIC)
  240. OR DEFINED(MORPHOS)
  241. OR DEFINED(NATIVENT)
  242. OR DEFINED(WINDOWS)}
  243. {$DEFINE THANDLE_CPUBITS}
  244. {$IFEND}
  245. {$IF DEFINED(BSD)}
  246. //I think BSD might handle FreeBSD, NetBSD, OpenBSD, and Darwin
  247. {$IF DEFINED(IOS)}
  248. {$IFDEF CPUARM64}
  249. {$DEFINE CPU64}
  250. {$DEFINE THANDLE_64}
  251. {$ELSE}
  252. {$IFDEF CPUARM32}
  253. {$DEFINE CPU32}
  254. {$ENDIF}
  255. {$DEFINE THANDLE_32}
  256. {$ENDIF}
  257. {$ELSEIF DEFINED(OSX)}
  258. {$IFDEF FPC}
  259. {$DEFINE THANDLE_32}
  260. {$ELSE}
  261. {$DEFINE THANDLE_CPUBITS} // !!! ADDED OSX BY EMBT
  262. {$ENDIF}
  263. {$IFEND}
  264. {$ELSEIF DEFINED(LINUX)}
  265. {$IFDEF LINUX64}
  266. {$DEFINE CPU64}
  267. {$DEFINE THANDLE_64}
  268. {$ELSE}
  269. {$IFDEF LINUX32}
  270. {$DEFINE CPU32}
  271. {$ENDIF}
  272. {$DEFINE THANDLE_32}
  273. {$ENDIF}
  274. {$ELSEIF DEFINED(ATARI)
  275. OR DEFINED(BEOS)
  276. OR DEFINED(EMX)
  277. OR DEFINED(GBA)
  278. OR DEFINED(GO32)
  279. OR DEFINED(HAIKU)
  280. OR DEFINED(NDS)
  281. OR DEFINED(NETWARE)
  282. OR DEFINED(NETWARELIBC)
  283. OR DEFINED(OS2)
  284. OR DEFINED(PALMOS)
  285. OR DEFINED(SOLARIS)
  286. OR DEFINED(SYMBIAN)
  287. OR DEFINED(WII)
  288. OR DEFINED(WATCOM)}
  289. {$DEFINE THANDLE_32}
  290. {$IFEND}
  291. // end platform specific stuff for THandle size
  292. {$IFDEF THANDLE_CPUBITS}
  293. {$IFDEF CPU64}
  294. {$DEFINE THANDLE_64}
  295. {$ELSE}
  296. {$DEFINE THANDLE_32}
  297. {$ENDIF}
  298. {$ENDIF}
  299. {$IF (NOT DEFINED(FREE_ON_FINAL))
  300. AND (DEFINED(HAS_System_RegisterExpectedMemoryLeak) OR DEFINED(USE_FASTMM4) OR DEFINED(USE_MADEXCEPT) OR DEFINED(USE_LEAKCHECK))}
  301. {$DEFINE REGISTER_EXPECTED_MEMORY_LEAK}
  302. {$IFEND}
  303. {
  304. We must determine what the SocketType parameter is for the Socket function.
  305. In Kylix and the libc.pas Kylix-compatibility library, it's a __socket_type.
  306. In BaseUnix, it's a C-type Integer. In Windows, it's a LongInt.
  307. }
  308. {$UNDEF SOCKETTYPE_IS_CINT}
  309. {$UNDEF SOCKETTYPE_IS___SOCKETTYPE}
  310. {$UNDEF SOCKETTYPE_IS_LONGINT}
  311. {$UNDEF SOCKETTYPE_IS_NUMERIC}
  312. {$UNDEF SOCKET_LEN_IS_socklen_t}
  313. {$IF DEFINED(USE_BASEUNIX)}
  314. {$DEFINE SOCKETTYPE_IS_CINT}
  315. {$DEFINE SOCKETTYPE_IS_NUMERIC}
  316. {$ELSEIF DEFINED(KYLIXCOMPAT)}
  317. {$DEFINE SOCKETTYPE_IS___SOCKETTYPE}
  318. {$ELSEIF DEFINED(USE_VCL_POSIX)}
  319. {$DEFINE SOCKETTYPE_IS_NUMERIC}
  320. {$DEFINE SOCKETTYPE_IS_LONGINT}
  321. {$DEFINE SOCKET_LEN_IS_socklen_t}
  322. {$ELSEIF DEFINED(WINDOWS)}
  323. {$DEFINE SOCKETTYPE_IS_LONGINT}
  324. {$DEFINE SOCKETTYPE_IS_NUMERIC}
  325. {$ELSEIF DEFINED(OS2)}
  326. {$DEFINE SOCKETTYPE_IS_LONGINT}
  327. {$DEFINE SOCKETTYPE_IS_NUMERIC}
  328. {$ELSEIF DEFINED(NETWARE)}
  329. {$DEFINE SOCKETTYPE_IS_LONGINT}
  330. {$DEFINE SOCKETTYPE_IS_NUMERIC}
  331. {$IFEND}
  332. {Take advantage of some TCP features specific to some stacks.
  333. They work somewhat similarly but there's a key difference.
  334. In Linux, TCP_CORK is turned on to send fixed packet sizes and
  335. when turned-off (uncorked), any remaining data is sent. With
  336. TCP_NOPUSH, this might not happen and remaining data is only sent
  337. before disconnect. TCP_KEEPIDLE and TCP_KEEPINTVL so the IFDEF LINUX and IFDEF
  338. SOLARIS instead of IFDEF UNIX is not an error, it's deliberate.}
  339. {$IF DEFINED(BSD) OR DEFINED(HAIKU)}
  340. {$DEFINE HAS_TCP_NOPUSH}
  341. {$ELSE}
  342. {$UNDEF HAS_TCP_NOPUSH}
  343. {$IFEND}
  344. {$IF DEFINED(LINUX) OR DEFINED(SOLARIS) OR DEFINED(NETBSD)}
  345. {$DEFINE HAS_TCP_CORK}
  346. {$ELSE}
  347. {$UNDEF HAS_TCP_CORK}
  348. {$IFEND}
  349. {$IF DEFINED(LINUX) OR DEFINED(NETBSD)}
  350. {$DEFINE HAS_TCP_KEEPIDLE}
  351. {$DEFINE HAS_TCP_KEEPINTVL}
  352. {$ELSE}
  353. {$UNDEF HAS_TCP_KEEPIDLE}
  354. {$UNDEF HAS_TCP_KEEPINTVL}
  355. {$IFEND}
  356. {$IFDEF USE_VCL_POSIX}
  357. // TODO: which POSIX platforms actually have SO_NOSIGPIPE available?
  358. {$IF DEFINED(ANDROID) OR DEFINED(LINUX)}
  359. {$UNDEF HAS_SOCKET_NOSIGPIPE}
  360. {$ELSE}
  361. {$DEFINE HAS_SOCKET_NOSIGPIPE}
  362. {$IFEND}
  363. {$ELSE}
  364. // TODO: which FPC platforms actually have SO_NOSIGPIPE available?
  365. {$UNDEF HAS_SOCKET_NOSIGPIPE}
  366. {$ENDIF}
  367. {end Unix OS specific stuff}
  368. {$IFDEF DEBUG}
  369. {$UNDEF USE_INLINE}
  370. {$ENDIF}