C++Builder Changes for XE2

From RAD Studio XE2
Jump to: navigation, search

Go Up to What's New in Delphi and C++Builder XE2

C++Builder XE2 supports cross-platform development for Mac OS X. The only Windows platform supported for C++Builder XE2 is the native Win32 platform; however, Delphi XE2 supports application development for the Win64 platform.

Introducing BCCOSX, the C++ Cross Compiler for OS X

C++Builder supports cross-platform development for the Mac OS X platform. The IDE uses the new BCCOSX cross compiler to compile cross-platform applications that run on the Mac OS X target platform.

New Macros

Two new predefined macros have been added specifically for the cross-platform applications that target the Mac OS X platform:

  • __MACH__
  • __APPLE__

For more information, see Predefined Macros.

Two macros have been added that set the C++ deprecated attribute:

If you plan to use the new C++ Audits, be aware that C++ Audits do not support the C++0x deprecated attribute. Check your code and use the new _DEPRECATED_ATTRIBUTE0_ or _DEPRECATED_ATTRIBUTE1 (text)_ macro instead of the deprecated attribute.

XLINK for Linking Mac OS X Applications

A new cross-platform linker, XLINK.exe, has been introduced for linking C++ applications that target the Mac OS X platform.

XLINK.exe supports several command options that are platform-specific and are not supported by ILINK32.exe:

Option Command


Generate Mach executable.


Generate Mach dylib.


Generate Mach package.


Link Mac framework.


Set remote profile path.


Set root directory: SYSROOT.

For more information, see:

Platform-Specific Paths and Directories for C++ or Delphi Projects

For cross-platform application development, you can now associate a specific set of paths and directories with a target platform (such as OS X or 64-bit Windows):


The new Selected Platform field is located at the top of the following pages in Tools > Options:

Boost Library Available for OS X Platform

If you install the Boost Library when you install RAD Studio, the Boost Library for Mac OS X is also installed on your development system. This is in addition to the Boost Library for Windows.

Extended RTTI for Delphi-style Classes

The C++ compiler emits more detailed RTTI for Delphi-style classes. Any member kind (method, field, property) of any visibility (__published, public, protected, private) can have RTTI. A new pragma directive can be used to selectively enable or disable the RTTI generation of specific members: #pragma explicit_rtti (similar to {$RTTI}).

Execution Character Set (-CE) Option Added to C++ Compiler Advanced Options

The Execution character set specifies the character set that is used for ANSI strings in the executable file.

See C++ Compiler Advanced.

New Project Options on C++ Linker Page

The C++ Linker now supports the following new options:

  • Static Package Library (-Gl) Option: Building a C++ static package library (.lib) requires a set of .objs that are different from the .objs used to build the dynamic library (.bpl). The -Gl option creates two sets of .objs—one for the static library and one for the dynamic library. See also: Building Static Packages.
  • Link with Delphi Runtime Library Option: Use this option for any C++ application that has no framework affinity and that you want to use some Delphi types (such as UnicodeString, Variant, and so on) or access some functionality exposed by units in the Delphi RTL package (such as SysUtils, Classes, IOUtils, and so on). For more details, see [C++ Linker]].

Use TLIBIMP Instead of #import for Importing Type Libraries

Although C++Builder XE2 supports #import, this support exists only for backwards compatibility with Microsoft. If you use #import, you will receive warning W8137 Deprecated #import directive encountered. Please use the TLIBIMP utility instead. (C++).

Note: Using #import is strongly discouraged; instead you should use TLIBIMP.EXE, so that you get the correct results. If your existing code uses #import, you will need to make code changes. You should migrate existing C++ code from #import to TLIBIMP.EXE (the reasons are described in the topic).

Also see Mapping Symbol Names in a Type Library for information about using tlibimp.sym to map symbol names for imported type libraries.

New Error and Warning Messages

W8136 Initialization of TLS data is not supported on this platform (C++)

You must initialize thread-local storage (TLS) data for a Mac OS X application at run time.

W8137 Deprecated #import directive encountered. Please use the TLIBIMP utility instead. (C++)

This warning is emitted when you attempt to import a type library using #import, which incorrectly handles the import. To correctly import a type library, you must use either of the following:

For more information, see Migrating C++ Code from #import to TLIBIMP.EXE.

C++ Source Code Audits

C++Builder provides the wide range of C++ Audits that help you to check for compliance with C++ coding style, maintenance, and robustness guidelines.