Cross-Platform Development

From Real Software Documentation

Jump to: navigation, search

Using Target Flags

You can develop your application on one platform and compile it for any other platforms that Real Studio supports. If your application will run on more than one platform, you can use the following global Boolean constants to determine which type of code is currently executing.


Boolean Constant Description
DebugBuild The application is running within the Real Studio application, i.e., from clicking the Run button in the IDE toolbar.
RBVersion Returns the version of Real Studio that is being compiled. You can use this in an expression that evaluates to True or False to determine which version of Real Studio is compiling the application.
TargetBigEndian The compiled application is running on a machine and OS that uses the Big Endian byte ordering.
TargetCarbon The compiled application is currently running Carbon/Mac OS X code.
TargetCocoa New in 2010r3 The compiled application is currently running Cocoa/Mac OS X code. in Real Studio 2010r3, Cocoa is being made available as a "beta" release.
TargetHasGUI The application has a GUI, i.e., it is not a ConsoleApplication or a ServiceApplication.
TargetLinux New in 5.5 The compiled application is running Linux code.
TargetLittleEndian The compiled application is running on a machine and OS that uses the Little Endian byte ordering.
TargetMachO New in 5.5 The compiled application is running on Mac OS X, running object code in the format for the Mach kernel.
TargetMacOS The compiled application is currently running Macintosh code, for either Cocoa or Carbon frameworks.
TargetWin32 The compiled application is currently running Win32 code.
Targetx86 The compiled application is currently running on x86 hardware, regardless of OS.

Conditional Compilation

If some of your code should be compiled only for a particular target platform (such as AppleScript-specific code or Declare statements), you can use #If statements to compile that code only for the appropriate platform. Use the following structure:


#If TargetBoolean
//OS-specific code
//included in built app
//only for target platform
#Else (optional) (optional code)

#ElseIf TargetBoolean //(optional)
//(optional) Other OS-specific code
#Endif
Personal tools