C/C++ Project Properties, Managed, C/C++ Build, Macros

Customizes the build macros used in your build configuration.

C/C++ Project Properties, Managed, C/C++ Build, Macros

Project Type:
Displays the type of project that is built by the selected build configuration.
Configuration:
Select the build configuration from the list provided.
Manage...
You can add, remove and rename configurations.
Configuration Settings
You can add and remove build macros for a project or configuration.  Each tab contains two tables - one for User defined build macros and one for non user-defined build macros.  Each table contains three columns:

Name of the build macro

Type of value contained in the build macro (see below)

Value of the build macro. 

You can view all build macros that are not user-defined in the System Macros table.  You can choose to also display all macros defined for lower-precedence contexts in the System Macros table by checking the Show parent context macros checkbox.

You can view all user-defined macros in the User Macros table.   A user-defined macro overrides a non user-defined macro of the same name for the given context.  Overridden macros are displayed in bold in the System Macros table.

Restore Defaults
Returns any changes back to their default setting.
Apply
Applies any changes.

Detailed Specification

Build Macros can be used in all C/C++ Build configuration properties that accept text. Build Macros are referenced in strings by enclosing them in braces, preceded by a dollar sign. There are no special restrictions on a macro name, though it is encouraged that a macro name begin with a letter and contain only letters, digits and underscore signs. Build macro names are case sensitive.
If the actual value of text property contains ${text}, it must be pre-pended with the backslash in order to distinguish it from a build macro. The Managed Build System pre-defines many useful macros (see below) and allows tool integrators and users to define additional macros.

Build Macros can hold several types of values:

  1. Text value: can be any text string
  2. Text-List value: an array of Text values
  3. Path-file value: can hold a file path
  4. Path-dir value: can hold a directory path
  5. Path-any value: can hold both a file and directory path
  6. Path-file-List value: an array of Path-file values
  7. Path-dir-List value: an array of Path-dir values
  8. Path-any-List value: an array of Path-any values

Build Macros are context-sensitive, that is the macro of a given name could have different values depending on where it is used.  Several contexts are defined:

  1. The currently selected file.

  2. The currently selected option

  3. The currently selected configuration (which includes a tool-chain).

  4. The currently selected project.

  5. The current workspace.

  6. The CDT and Eclipse installations.

  7. The process environment variables defined in the environment passed to Eclipse.

Users can define new macros for any project or configuration of a project.  The value of a build macro will be searched for in the order specified above. If macro is not found for the currently selected file context, the currently selected option context will be used, if not found, the currently selected configuration context will be used, etc. 

Macro resolution takes place when the build file is being generated.

All macros except the build process environment macros always get resolved in the makefile.  See the ??“expand build environment macrosâ€? checkbox in the “Build Settingsâ€? tab of the “C/C++ Buildâ€?.

The Managed Build System pre-defines many useful macros described in the following tables:

File-specific macros

The set of file-context macros is MBS-predefined, neither a tool-integrator nor a user can define new file-context macros, but a tool-integrator can specify the values for the file-context macros using attributes of a builder element. The macro values specified in those attributes should not contain the explicit e.g. file name, but instead should provide the filename definition in terms of the builder automatic variables and text functions. This is needed to allow the makefile generator to generate pattern rules, e.g. in the case of Gnu make, the macro that represents the output file name will contain the “$(notdir $@)? value. The builder definition of the gnu tool-chain will contain attribute specifying the value for that macro. If a tool-integrator does not provide the values for the file-specific macros, MBS will automatically expand them to their actual value when generating the buildfile, e.g. for the foo.c file the macro that represents the input file name will contain “foo.c? in this case. In this case the makefile generator will not be able to use pattern rules for building files with options containing file-specific macros. (see the “Supplying the file-context macros values? section for more detail)

Macro

Value Type

Description

${InputFileName}

Text

Represents the input file name. The input file has the following meaning:

1.      If a tool does not accept building multiple files of the primary input type with one tool invocation, the input file is the file of the primary input type being built.

2.      If a tool accepts building multiple files of the primary input type with one tool invocation the input file is undefined and the macros representing the input file contain information about one of the inputs of the primary input type being built.

${InputFileExt}

Text

Represents the extension of the input file.

${InputFileBaseName}

Text

Represents the base name of the input file. That is the file name with an extension stripped.

${InputFileRelPath}

Path(File)

Represents the input file path relative to the builder current directory.

${InputDirRelPath}

Path(Dir)

Represents the input file directory path relative to the builder current directory.

${OutputFileName}

Text

Represents the output file name. The output file has the following meaning:

1.      If a tool is not capable of producing multiple files of the primary output type with one tool invocation the output file is the file of the primary output type that is built with a given tool invocation.

2.      If a tool is capable of producing multiple files of the primary output type with one tool invocation the output file is undefined and the macros representing the output file contain information about one of the files of the primary output type that are built with a given tool invocation.

${OutputFileExt}

Text

Represents the output file extension.

${OutputFileBaseName}

Text

Represents the output file base name. That is the output file name with an extension stripped.

${OutputFileRelPath}

Path(File)

Represents the output file path relative to the current builder directory.

${OutputDirRelPath}

Path(Dir)

Represents the output file directory path relative to the current builder directory.

 Configuration-specific macros

Macro

Value Type

Description

${ConfigName}

Text

Represents the name of a given configuration.

${ConfigDescription}

Text

Represents the description of a given configuration.

${BuildArtifactFileName}

Text

Represents the name of the build artifact.

${BuildArtifactFileExt}

Text

Represents the extension of the build artifact.

${BuildArtifactFileBaseName}

Text

Represents the base name of the build artifact.

${BuildArtifactFilePrefix}

Text

Represents the prefix of the build artifact.

${TargetOsList}

Text-List

Represents the list of the target OS names.

${TargetArchList}

Text-List

Represents the list of the target Arch names.

Project-specific macros

${ProjName}

Text

Represents the name of a given project.

${ProjDirPath}

Path(Dir)

Represents the absolute path of a given project.

Workspace-specific macros

${WorkspaceDirPath}

Path(Dir)

Represents the workspace absolute path.

${DirectoryDelimiter}

Text

Represents the directory delimiter used on the system. That is the “\? for Win32 systems and the “/? for Unix-like systems

This could be useful, e.g. in the case a user needs the absolute path of an input file. The absolute path would be represented in the following way: ${CWD}${DirectoryDelimiter}${InputFileRelPath}

${PathDelimiter}

Text

Represents the default path delimiter used on the system to separate paths in the path environment variables. That is the “;? for Win32 systems and the “:? for Unix-like systems

This might be used in the environment variable definitions

CDT/Eclipse installation-specific macros

${EclipseVersion}

Text

Represents the current eclipse version.

${CDTVersion}

Text

Represents the current CDT version.

${MBSVersion}

Text

Represents the current MBS version.

${HostOsName}

Text

Represents the operating system name on which eclipse is running.

${HostArchName}

Text

Represents the architecture name on which eclipse is running.

Related reference
C++ Project Properties, Standard, Info
C++ Project Properties, Standard, Builders
C++ Project Properties, Standard, File Types
C++ Project Properties, Standard, Include Paths and Symbols
C++ Project Properties, Standard, Indexer
C++ Project Properties, Standard, Make Builder
C++ Project Properties, Standard, Error Parser
C++ Project Properties, Standard, Binary Parser
C++ Project Properties, Standard, Discovery Options
C++ Project Properties, Standard, Source
C++ Project Properties, Standard, Output
C++ Project Properties, Standard, Projects
C++ Project Properties, Standard, Libraries
C++ Project Properties, Standard, Path Containers
C++ Project Properties, Standard, Project References
C++ Project Properties, Managed, Info
C++ Project Properties, Managed, Builders
C++ Project Properties, Managed, C/C++ Build
C++ Project Properties, Managed, C/C++ Build, Tool Settings
C++ Project Properties, Managed, C/C++ Build, Build Settings
C++ Project Properties, Managed, C/C++ Build, Build Steps
C++ Project Properties, Managed, C/C++ Build, Error Parsers
C++ Project Properties, Managed, C/C++ Build, Binary Parser
C++ Project Properties, Managed, C/C++ Build, Environment
C++ Project Properties, Managed, C/C++ Documentation
C++ Project Properties, Managed, C/C++ File Types
C++ Project Properties, Managed, C/C++ Indexer
C++ Project Properties, Managed, Project References

IBM Copyright Statement