As part of building a shared library, plug-in, or other software that will export symbols, you want to specify which symbols are available to clients of the software. The fewer symbols your software exports, the more quickly it will load at runtime. In addition, you typically do not want to expose internal entry points, due to both competitive and support issues.
CodeWarrior provides several options for specifying which symbols a shared library will export.
Use an export (or .exp) file. When you run the Make command on a library target, CodeWarrior creates a .exp file containing all the global variables and routines in the project. After creating this file, you can comment out any symbols you don’t want to export, including CodeWarrior runtime symbols. You then add the .exp file to the appropriate target and rebuild the project.
You can use the pragma statements #pragma export on and #pragma export off to bracket any symbols you want to export. CodeWarrior exports only symbols bracketed by these statements.
Combine the two previous mechanisms. Only the bracketed symbols are placed in the .exp file, which you can still edit as necessary.
You can include your export file in an Xcode project as well, by setting the Exported Symbols File build setting to the name of your export file. Xcode passes the appropriate options to the static linker.
Note: The static linker also supports the -unexported_symbols_list option to specify a file containing symbols that should not be exported. However, there is currently no built-in build setting in the Xcode interface for setting this option.
You can’t use the pragma statements #pragma export on and #pragma export off to specify export symbols in Xcode because GCC does not support these pragma statements. However, GCC does have its own pragmas for controlling symbol visibility, described in C++ Runtime Environment Programming Guide.
Beginning with Xcode 2.2, the importer interprets the Export Symbols setting in your CodeWarrior target. Based on the following values for that setting, the importer configures the corresponding Xcode target differently:
None. The importer enables the Symbols Hidden by Default (GCC_SYMBOLS_PRIVATE_EXTERN) and Inline Functions Hidden (GCC_INLINES_ARE_PRIVATE_EXTERN) build settings for the new Xcode target. When these build settings are enabled, all symbols are declared 'private extern' unless explicitly marked otherwise.
All Globals. The importer disables the Symbols Hidden by Default (GCC_SYMBOLS_PRIVATE_EXTERN) build setting in the new Xcode target.
'Use ".exp" file' or 'Use #pragma and ".exp" file.' The importer sets the Exported Symbols File (EXPORTED_SYMBOLS_FILE) build setting to the path to the first export file that it finds in your CW target. It also enables the Symbols Hidden by Default and Inline Functions Hidden build settings.
Note that, while CodeWarrior targets may have multiple .exp files, an Xcode target can have only one. If your CW target has more than one export file, the importer uses the first one it encounters and ignores the rest.
The importer does not interpret the Referenced Globals or Use #pragma settings.
For related information in this document, see “Runtime and Library Issues,” “Dead Code Stripping,” and “Pragma Statements.”
For additional information on examining and managing your software’s exported symbols, and on other techniques for producing more efficient code, see Code Size Performance Guidelines. In particular, the section “Minimizing Your Exported Symbols” describes how to reduce the symbols exported by your application.
Last updated: 2006-10-26