Show: Delphi C++
Display Preferences

C++ Considerations for Cross-Platform Applications

From RAD Studio XE2
Jump to: navigation, search

Go Up to Cross-Platform Applications Index


Contents


Stack Alignment Issue on OS X

For OS X applications, all memory data must be stack-aligned on 16-byte boundaries:

Available C/C++ Header Files

RAD Studio provides separate C/C++ header files for different target platforms. These files are located in the $(BDS)\include standard search path.

To use header files from a remote search path, see Add Remote Path Item or Edit Remote Path Item. For example, on OS X you can add the OpenGL and GLUT libraries, as described in the code example OpenGL Multicolor Tetrahedron (C++). The Platform Assistant Client copies automatically the files from remote paths to the development system. (You must have installed the Platform Assistant Server on the remote system.)

For Mac OS X

The header files for Mac OS X are located on the development PC in $(BDS)\include\osx.

Sub-directory in
$(BDS)\include\osx
Description
\crtl C/C++ RTL header files (.h). Some of these files include the C/C++ header files located on Mac in the /usr/include directory. For more information see OS X C RTL.
\rtl Delphi RTL machine generated header files (.hpp).

For Win32

The header files for Win32 are located in $(BDS)\include\windows. The Win64 target platform is not supported by C++Builder.

Subdirectory in
$(BDS)\include\windows
Description
\crtl C/C++ RTL header files (.h). For more information see C Runtime Library Reference Index.
\fmx FireMonkey machine generated header files (.hpp)
\rtl Delphi RTL machine generated header files (.hpp)
\sdk Microsoft Windows SDK header files (.h)
\vcl VCL machine generated header files (.h and .hpp)

Framework Availability on Different Platforms

VCL

The VCL supports development on Windows only (both 32-bit and 64-bit). (C++Builder does not support 64-bit Windows yet.)

FireMonkey

The FireMonkey or FMX framework is supported on Mac OS X, 32-bit Windows, and 64-bit Windows. (C++Builder does not support 64-bit Windows yet.)

Delphi RTL (different from the C/C++ RTL)

The Delphi run-time library is supported on Mac OS X, 32-bit Windows, and 64-bit Windows. (C++Builder does not support 64-bit Windows yet.)

Using Frameworks on the OS X Platform

The BCCOSX and XLINK options related to Mac frameworks are described in the following table:

Tool Option Description
BCCOSX --sysroot When the linker is invoked, this option is converted to the -Fr option.
BCCOSX --framework When the linker is invoked, this option is converted to the -Ff option.
XLINK -Fr Specifies the location of the logical root directory. The logical root directory is a directory on the local (Windows) machine that represents the root of the remote (Mac OS X) machine.
XLINK -Fp Specifies the remote library paths. Also see the -L option.
XLINK -Ff Instructs the linker to link the specified framework. For more information, see the --framework documentation.

For a description of how to instruct BCCOSX and XLINK to link to Mac frameworks, see --framework.

For more information on Mac frameworks, see Mac OS X Application Development#Using Frameworks in Mac Apps.


String Literals char16_t and wchar_t on the OS X Platform

On Mac OS X, char16_t is not equivalent to wchar_t (as it is on Windows):

  • On Windows, wchar_t and char16_t are both double-byte characters.
  • On Mac, however, a wchar_t is a 4-byte character.

So, to declare UTF-16 constant strings, on Windows use either the L or the u prefix, whereas on Mac use the u prefix.

Example on Windows:

UnicodeString(L"Text"), UnicodeString(u"Text")

Example on Mac:

UnicodeString(u"Text")

Using the L prefix for string literals on Mac OS X is not, however, wrong. In this case, UTF-32 constant strings are converted to UTF-16 strings.

For portability, use the _D macro to write constant strings that are prefixed accordingly with L or u. Example:

UnicodeString(_D("Text"))

Inline Assembly Restriction

You can write IA-32 (including SSE4.2) inline assembly in C++ code for OS X, but you cannot compile C++ code to assembly.


See Also

Personal tools
Previous Versions
In other languages