Show: Object Pascal C++
Display Preferences

C++ Considerations for Multi-Device Applications

From Appmethod Topics
Jump to: navigation, search

Go Up to Multi-Device Applications Index

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

Appmethod 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 an SDK 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++). You can manage your SDKs from Tools > Options > Environment Options > SDK Manager.

For Windows

The header files for 32-bit Windows and 64-bit Windows are located in $(BDS)\include\windows.

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 Object Pascal RTL machine generated header files (.hpp)
   \sdk Microsoft Windows SDK header files (.h)
   \vcl VCL machine generated header files (.h and .hpp)

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.
   \fmx FireMonkey machine generated header files (.hpp)
   \rtl Object Pascal RTL machine generated header files (.hpp).

For iOS

The header files for iOS are located on the development PC in $(BDS)\include\ios.

Sub-directory in
$(BDS)\include\ios
Description
   \crtl C/C++ RTL header files (.h). For more information see iOS C RTL.
   \fmx FireMonkey machine generated header files (.hpp)
   \rtl Object Pascal RTL machine generated header files (.hpp).

For Android

The header files for Android are located on the development PC in $(BDS)\include\android.

Sub-directory in
$(BDS)\include\android
Description
   \crtl C/C++ RTL header files (.h). For more information see Android C RTL.
   \fmx FireMonkey machine generated header files (.hpp)
   \rtl Object Pascal RTL machine generated header files (.hpp).

Framework Availability on Different Platforms

Using Frameworks

On Mac OS X

The compiler and linker options related to Mac frameworks are described in the following table:

Tool Option Description
C++ Compiler for Mac OS X --sysroot When the linker is invoked, this option is converted to the -Fr option.
C++ Compiler for Mac OS X --framework When the linker is invoked, this option is converted to the -Ff option.
C++ Cross-Platform Linker -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.
C++ Cross-Platform Linker -Fp Specifies the remote library paths. Also see the -L option.
C++ Cross-Platform Linker -Ff Instructs the linker to link the specified framework.


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

On iOS and Android

The compiler options related to iOS and Android frameworks are described in the following table:

Tool Option Description
C++ compiler for the iOS Device -isysroot Specifies the root of the iOS SDK. This is typically set to %IOS_SDK_ROOT% or %ANDROID_SDK_ROOT%.
C++ compiler for the iOS Device -F Specifies the framework path. This is typically set to %IOS_SDK_ROOT%\System\Library\Frameworks" or %ANDROID_SDK_ROOT%\System\Library\Frameworks".
LD -syslibroot Specifies the location of the logical root directory. The logical root directory is a directory on your development PC (Windows) that represents the root of the iOS SDK.
LD -framework Specifies a framework to link. For example, -framework Foundation links your application to the Foundation framework.

On the IDE, in Project > Options > C++ Compiler > Directories and Conditionals, you can use the "Framework root directories" project option to define directories to add to the framework include path.

String Literals char16_t and wchar_t on Mac OS X and iOS

On Mac OS X and iOS, 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 OS X, iOS, and Android, 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 OS X, iOS, and Android, use the u prefix.

Example on Windows:

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

Example on Mac OS X, iOS, and Android:

UnicodeString(u"Text")

Using the L prefix for string literals on Mac OS X, iOS, and Android 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"))

For information about the mobile platforms, see Resolving Linker Warnings about String Literals.

See Also

Personal tools
In other languages