GR32_Compiler.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. (* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1 or LGPL 2.1 with linking exception
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * Alternatively, the contents of this file may be used under the terms of the
  15. * Free Pascal modified version of the GNU Lesser General Public License
  16. * Version 2.1 (the "FPC modified LGPL License"), in which case the provisions
  17. * of this license are applicable instead of those above.
  18. * Please see the file LICENSE.txt for additional information concerning this
  19. * license.
  20. *
  21. * The Original Code is Graphics32
  22. *
  23. * The Initial Developer of the Original Code is
  24. * Alex A. Denisov
  25. *
  26. * Portions created by the Initial Developer are Copyright (C) 2000-2009
  27. * the Initial Developer. All Rights Reserved.
  28. *
  29. * ***** END LICENSE BLOCK ***** *)
  30. (*
  31. Supported compilers:
  32. --------------------
  33. Name CompilerVersion
  34. -------------------------------------------
  35. Delphi 12 Yukon 36.0
  36. Delphi 11 Alexandria 35.0
  37. Delphi 10.4 Sydney 34.0
  38. Delphi 10.3 Rio 33.0
  39. Delphi 10.2 Tokyo 32.0
  40. Delphi 10.1 Berlin 31.0
  41. Delphi 10 Seattle 30.0
  42. Delphi XE8 29.0
  43. Delphi XE7 28.0
  44. Delphi XE6 27.0
  45. Delphi XE5 26.0
  46. Delphi XE4 25.0
  47. Delphi XE3 24.0
  48. Delphi XE2 23.0
  49. FreePascal 3.2.2
  50. This file previously defined the following symbols:
  51. COMPILERFPC - FPC (since version 2.6.0)
  52. COMPILER6 - Delphi 6
  53. COMPILER7 - Delphi 7
  54. COMPILER2005 - Delphi 2005
  55. COMPILER2006 - Delphi 2006 / BDS 2006
  56. COMPILER2007 - Delphi / RAD Studio 2007
  57. COMPILER2009 - Delphi 2009
  58. COMPILER2010 - Delphi 2010
  59. COMPILERXE1 - Delphi XE
  60. COMPILERXE2 - Delphi XE2
  61. COMPILERXE3 - Delphi XE3
  62. COMPILERXE4 - Delphi XE4
  63. COMPILERXE5 - Delphi XE5
  64. COMPILERXE6 - Delphi XE6
  65. COMPILERXE7 - Delphi XE7
  66. COMPILERXE8 - Delphi XE8
  67. COMPILERRX - Delphi RX (10 Seattle)
  68. COMPILERRX1 - Delphi RX1 (10.1 Berlin)
  69. COMPILERRX2 - Delphi RX2 (10.2 Tokyo)
  70. COMPILERRX3 - Delphi RX3 (10.3 Rio)
  71. COMPILERRX4 - Delphi RX4 (10.4 Sydney)
  72. COMPILERRX5 - Delphi 11 (Alexandria)
  73. COMPILERRX6 - Delphi 12 (Athens)
  74. The above symbols have all been deprecated. Instead use the following symbols:
  75. FPC - FreePascal
  76. DCC - Delphi
  77. BCB - C++ Builder
  78. CompilerVersion - Delphi version
  79. Available Targets:
  80. ------------------
  81. TARGET_x86 - x86 (32-Bit)
  82. TARGET_x64 - x86 (64-Bit)
  83. TARGET_POWERPC - Power PC
  84. TARGET_ARM - ARM processor
  85. *)
  86. {$if defined(FPC)}
  87. {...}
  88. {$elseif (CompilerVersion < 23.0)} // Delphi XE2 and later
  89. {$Message Fatal 'Graphics32 only supports Delphi/BCB XE2 (or higher) or Free Pascal / Lazarus'}
  90. {$elseif (CompilerVersion > 36.0)} // Newer than this file but we'll take it
  91. {$Message Hint 'Unknown compiler version. Assuming compatible with last known version.'}
  92. {$else} // Delphi XE3 and later
  93. {$LEGACYIFEND ON} // Stupid. Required for XE4+ but introduced in XE3.
  94. {$ifend}
  95. (*
  96. Symbol INLININGSUPPORTED:
  97. -------------------------
  98. In modern Delphi versions procedures and functions that do not contain
  99. assembler code can be inlined. This can be extremely useful for calls
  100. to a small portion of code in a loop. However, depending on the instruction
  101. cache size, this may or may not result in a performance boost compared to a
  102. call of assembler optimized code.
  103. *)
  104. // Note: Inlining is supported by all supported compilers; This define will be deprecated.
  105. {$if not defined(MEDIOCRE_COMPILER)}
  106. {$define INLININGSUPPORTED}
  107. {$ifend}
  108. (*
  109. Symbol TARGET_* :
  110. -----------------
  111. Defines the processor platform (x86, x64 or PowerPC)
  112. *)
  113. {$ifdef FPC}
  114. // Set up internal CPU target directives according to FPC directives
  115. {$if defined(CPU386)}
  116. {$if defined(CPUI386)}
  117. // target is an Intel 80386 or later.
  118. {$define TARGET_x86}
  119. {$ASMMODE INTEL}
  120. {$elseif defined(CPUX86_64)}
  121. // target is a 64-bit processor (AMD or INTEL).
  122. {$define TARGET_x64}
  123. {$ASMMODE INTEL}
  124. {$elseif defined(CPUPOWERPC)}
  125. // target is a 32-bit PowerPC or compatible.
  126. // currently only indirect support, added here as example on how to add
  127. // future specific targets
  128. {$define TARGET_POWERPC}
  129. {$ifend}
  130. {$elseif defined(CPUX86_64)}
  131. // target is a 64-bit processor (AMD or INTEL).
  132. {$define TARGET_x64}
  133. {$ASMMODE INTEL}
  134. {$elseif defined(CPUARM)}
  135. // target is an ARM processor.
  136. {$define TARGET_ARM}
  137. {$ifend}
  138. {$else}
  139. // check for XE2 64-Bit compiler define
  140. {$if defined(CPUX64)}
  141. {$define TARGET_x64}
  142. {$else}
  143. // define default (delphi etc) target (32 bit Intel 80386 or later)
  144. {$define TARGET_x86}
  145. {$ifend}
  146. {$endif}
  147. (*
  148. Symbol FRAMEWORK_* :
  149. -----------------
  150. Defines the UI framework (VCL, FireMonkey, LCL)
  151. *)
  152. {$ifdef FPC}
  153. {$define FRAMEWORK_LCL}
  154. {$else}
  155. {$if declared(FireMonkeyVersion) or defined(FRAMEWORK_FMX)}
  156. {$define FRAMEWORK_FMX} // Defined as of Delphi 11.1
  157. {$else}
  158. {$define FRAMEWORK_VCL} // Defined as of Delphi 11.1
  159. {$ifend}
  160. {$endif}
  161. (*
  162. Symbol PUREPASCAL:
  163. ------------------
  164. Forces GR32 into pure pascal mode.
  165. NOTE: Further work needed to make assembly routines FPC compatible.
  166. NOTE: The DARWIN target of Free Pascal generates PIC code by default
  167. Which isn't compatible with the current assembler, so force PUREPASCAL
  168. *)
  169. {$ifdef FPC}
  170. {-$DEFINE PUREPASCAL}
  171. {$endif}
  172. {$ifdef TARGET_ARM}
  173. {$define PUREPASCAL}
  174. {$define OMIT_MMX}
  175. {$define OMIT_SSE2}
  176. {$endif}
  177. {$ifdef DARWIN}
  178. {$define PUREPASCAL}
  179. {$endif}
  180. (*
  181. Symbol BITS_GETTER:
  182. -------------------
  183. *)
  184. {$if defined(FPC) and (not defined(LCLWin32))}
  185. // Widgetsets other then Windows will want to implement BITS_GETTER
  186. {$define BITS_GETTER}
  187. {$ifend}
  188. (*
  189. Symbol NATIVE_SINCOS:
  190. ---------------------
  191. Use native FPU function to retrieve SIN/COS values for a given argument
  192. NOTE: On older systems a native call is typically much faster than calling
  193. Sin() and Cos() from a higher level library (such as the math/system unit)
  194. separately. However, on 64-bit systems a call can be slower, due to
  195. additional conversion between XMM registers and the FPU
  196. *)
  197. {$if defined(PUREPASCAL) or defined(TARGET_x64)}
  198. {$define NATIVE_SINCOS}
  199. {$ifend}
  200. (*
  201. Symbol: LOADFROMSTREAM
  202. ----------------------
  203. TGraphic has the CanLoadFromStream method.
  204. If this symbol is defined, Graphics32 will use TGraphics.CanLoadFromStream
  205. when loading an image format from a stream.
  206. TGraphics.CanLoadFromStream was introducen in Delphi 10.2
  207. *)
  208. {$if defined(FPC) or (CompilerVersion >= 32.0)}
  209. {$define LOADFROMSTREAM}
  210. {$ifend}
  211. (*
  212. Symbol: HAS_TPOINTF, HAS_TRECTF
  213. -------------------------------
  214. Use the RTL TPointF and TRectF types.
  215. If this symbol is defined, Graphics32 will alias the TFloatPoint and TFloatRect
  216. types to the RTL TPointF and TRectF types. Otherwise the types defined in
  217. GR32 will be used.
  218. The TPointF and TRectF types exists in Delphi XE2 and later, and in FPC.
  219. However, the FPC implementation of TRectF is pretty pathetic so we'll use our
  220. own there.
  221. *)
  222. {$define HAS_TPOINTF}
  223. {$ifndef FPC}
  224. {$define HAS_TRECTF}
  225. {$endif}
  226. (*
  227. Symbol: CLOSURE_CAPTURES_CONST
  228. -------------------------------
  229. Can anonymous methods capture const parameters.
  230. If this symbol is defined, the compiler is assumed to support capturing
  231. record types passed as const parameters (i.e. by reference) by value.
  232. procedure Test(const Value: TRect);
  233. begin
  234. DoTest(
  235. procedure(Value) // E2555 Cannot capture symbol 'Value'
  236. begin
  237. ...do something...
  238. end);
  239. end;
  240. The symbol is defined for Delphi 10.3 and later and for FPC.
  241. *)
  242. {$if defined(FPC) or (CompilerVersion >= 33.0)}
  243. {$define CLOSURE_CAPTURES_CONST}
  244. {$ifend}
  245. (*
  246. Miscellaneous Defines:
  247. ----------------------
  248. *)
  249. {$UNDEF USETHREADRESUME}
  250. {$ifdef LINUX}
  251. {$define UNIX}
  252. {$endif}
  253. (*
  254. ** Delphi
  255. ** ---------------------------------------
  256. *)
  257. {$if (not defined(FPC))}
  258. // Disable use of Doubles as intermediary values when calculating
  259. // Single precision expressions.
  260. {$if defined(TARGET_x64)}
  261. {$EXCESSPRECISION OFF}
  262. {$ifend}
  263. {$if defined(LINUX)}
  264. {$define BITS_GETTER}
  265. {$ifend}
  266. {$if defined(MSWINDOWS)}
  267. {$define Windows} // For backward compatibility; We use the MSWINDOWS define now
  268. {$ifend}
  269. {$define EXT_PROP_EDIT}
  270. {$define HasParentBackground}
  271. {$define SUPPORT_XPTHEMES} // enable support for windows xp themes
  272. // Features only supported by Delphi and not by FPC:
  273. {$define RECORD_CONSTRUCTORS} // Record type constructors
  274. {$define RECORD_CLASS_VAR} // Class vars in record types. Use object type instead.
  275. {$define CAST_INTF_TO_CLASS} // Casting an interface to a class.
  276. // 16 byte code alignment required for SSE aligned loads from asm db blocks
  277. {$CODEALIGN 16}
  278. // FireMonkey
  279. {$if defined(ANDROID) or defined(IOS)}
  280. {$define PLATFORM_INDEPENDENT}
  281. {$define PUREPASCAL}
  282. {$define NATIVE_SINCOS}
  283. {$define RGBA_FORMAT}
  284. {$ifend}
  285. {$define USE_FONT_QUALITY} // Apparently Font.Quality now also works with VCL. Not sure which version fixed it though...
  286. {$else}
  287. (*
  288. ** FPC
  289. ** ---------------------------------------
  290. *)
  291. {$MODE Delphi}
  292. {$define PLATFORM_INDEPENDENT}
  293. {$define FPC_HAS_CONSTREF}
  294. {$define NATIVE_SINCOS}
  295. // 16 byte code alignment required for SSE aligned loads from asm db blocks
  296. {$CODEALIGN PROC=16}
  297. {$ifndef MSWINDOWS}
  298. {$define RGBA_FORMAT}
  299. {$endif}
  300. {$if (not defined(TARGET_x86)) and (not defined(TARGET_x64))}
  301. // Target processor is neither x86 or x64: Use Pascal versions
  302. {$define PUREPASCAL}
  303. {$ifend}
  304. {$if defined(TARGET_x86)}
  305. // StackAlloc currently only works with 32-bit FPC
  306. {$define USESTACKALLOC}
  307. {$ifend}
  308. {-$define HasParentBackground} // FPC has ParentBackground but we haven't implemented support for it
  309. {$define USE_FONT_QUALITY} // Font.Quality works on LCL
  310. {$ifend}
  311. (*
  312. Miscellaneous compiler switches:
  313. --------------------------------
  314. *)
  315. {$R-}{$Q-} // switch off overflow and range checking
  316. (*
  317. Deprecated defines
  318. --------------------------------
  319. *)
  320. {$if defined(FPC)}
  321. {$define COMPILERFPC}
  322. {$else}
  323. {$define COMPILERXE2}
  324. {$define COMPILERXE3}
  325. {$define COMPILERXE4}
  326. {$define COMPILERXE5}
  327. {$define COMPILERXE6}
  328. {$define COMPILERXE7}
  329. {$define COMPILERXE8}
  330. {$define COMPILERRX}
  331. {$define COMPILERRX1}
  332. {$define COMPILERRX2}
  333. {$define COMPILERRX3}
  334. {$define COMPILERRX4}
  335. {$define COMPILERRX5}
  336. {$define COMPILERRX6}
  337. {$ifend}
  338. // FireMonkey
  339. {$IF Defined(ANDROID) or Defined(IOS)}
  340. {$DEFINE PLATFORM_INDEPENDENT}
  341. {$DEFINE PUREPASCAL}
  342. {$DEFINE NATIVE_SINCOS}
  343. {$DEFINE RGBA_FORMAT}
  344. {$IFEND}