5

Is compiler directive WIN32 and CPUX86, WIN64 and CPUX64 interchangeable in Delphi?

If yes, Which one is preferred? If no, why?

justyy
  • 5,831
  • 4
  • 40
  • 73

1 Answers1

13

Whether or not they are interchangeable depends on platforms you are developing for.

Generally, if you are doing only Windows development then they are interchangeable, otherwise not.

WIN32 is defined only for Windows 32bit platform, and WIN64 is defined only for Windows 64bit platform.

However, CPUX86 is defined for several platforms: Windows 32bit, OSX 32bit, and iOS 32bit simulator.

Right now WIN64 and CPUX64 are only defined for Windows 64bit platform, so at the moment they are interchangeable, but that may change in the future.

Which directive you should use depends on your code. Use directive that conveys proper meaning. If part of code is meant only to run on Windows 32bit platform then use WIN32 directive, if it is meant to run on any platform but under 32bit x86 processor then you should use CPUX86.

Predefined Conditionals

Dalija Prasnikar
  • 27,212
  • 44
  • 82
  • 159
  • Nice and clear answer. Actually I don't know why I am asking this simple question, I should have figured out by myself. – justyy Nov 07 '15 at 13:20
  • Great you mention the reference *Predefined Conditionals* - maybe even better if it was in a concluding sentence. – Wolf Jan 09 '19 at 09:30