About this document

This document contains information on setting up the compilation environment, how to compile, link, and run programs that are written in the C or C++ languages and how to specify compiler options, pragmas, macros and built-in functions in your application. The guide also contains extensive cross-references to the relevant sections of the other reference guides in the XL C/C++ documentation suite.

Who should read this document

This document is for anyone who wants to work with the XL C/C++ compiler and is familiar with the AIX operating system, and who has some previous C or C++ programming experience. However, users new to C or C++ can still use this document to find information on the capabilities and features unique to XL C/C++ compiler. This guide can help you understand what the features of the compiler are, especially the options, and how to use them for effective software development.

How to use this document

Throughout these pages, the xlc and xlc++ command invocations are used to describe the actions of the compiler. You can, however, substitute other forms of the compiler invocation command if your particular environment requires it, and compiler option usage will remain the same unless otherwise specified.

Unless indicated otherwise, all of the text in this reference pertains to both C and C++ languages. Where there are differences between languages, these are indicated through qualifying text and icons.

While this document covers information about configuring the compiler and compiling, linking and running C or C++ applications using XL C/C++ compiler, it does not include the following topics:

How this document is organized

This document starts with an overview of the compiler and provides you with the information on the tasks you need to perform before invoking the compiler. It then continues with providing the reference information about the compiler options, pragmas, built-in functions and macros.

Chapters 1 through 4 discuss topics related to setting up the compilation environment, including setting up environment variables and customizing the configuration file; types of input and output files; compiler listings and messages; and invoking the preprocessor and linkage editor.

Chapter 5 discusses different ways for specifying compiler options and resolving conflicting compiler options.

Chapter 6 talks about different ways to set include file path names and directory search sequence.

Chapter 7 contains a summary of options by their functional category, which allows you to look up and link to options by function. The chapter also includes individual descriptions of each compiler option sorted alphabetically sorted. Each description provides examples and a list of related topics.

Chapter 8 contains information on how to reuse GNU C/C++ compiler options through the use of the compiler invocation utility gxlc and gxlc++.

Chapters 9 to 11 contain individual descriptions of pragmas including OpenMP and SMP directives, compiler macros and built-in functions for POWER(TM) and PowerPC(R) architectures categorized by their functionality.

Appendix A discusses national language support in XL C/C++. Appendix B lists the ASCII character sets.

Conventions used in this document

Typographical conventions

The following table explains the typographical conventions used in this document.

Table 1. Typographical conventions
Typeface Indicates Example
bold Commands, executable names, compiler options and pragma directives. Use the -qmkshrobj compiler option to create a shared object from the generated object files.
italics Parameters or variables whose actual names or values are to be supplied by the user. Italics are also used to introduce new terms. Make sure that you update the size parameter if you return more than the size requested.
monospace Programming keywords and library functions, compiler built-in functions, file and directory names, examples of program code, compiler messages, command strings, or user-defined names. If one or two cases of a switch statement are typically executed much more frequently than other cases, break out those cases by handling them separately before the switch statement.


All features described in this document apply to both C and C++ languages. Where a feature is exclusive to one language, or where functionality differs between languages, the following icons are used:

C only
The text describes a feature that is supported in the C language only; or describes behavior that is specific to the C language.
C++ only
The text describes a feature that is supported in the C++ language only; or describes behavior that is specific to the C++ language.

How to read syntax diagrams

The following syntax diagram example shows the syntax for the #pragma comment directive.

 1   2    3    4         5         6                               9  10 
                          |                                     |
                          |                                     |
                          |                                     |
                             |             |  |                 | 
                             |             |  |                 |
                             +--user-------+  +--,-"characters"-+

                                                 7  8 

The following examples of the #pragma comment directive are syntactically correct according to the diagram shown above:

   #pragma comment(user)
   #pragma comment(copyright,"This text will appear in the module")


The examples in this document, except where otherwise noted, are coded in a simple style that does not try to conserve storage, check for errors, achieve fast performance, or demonstrate all possible methods to achieve a specific result.

IBM XL C/C++ publications

XL C/C++ provides product documentation in the following formats:

Related publications

You might want to consult the following publications, which are also referenced throughout this document: