In C++ language applications, this option instructs the compiler to try to inline functions. Inlining is performed if possible but, depending on which optimizations are performed, some functions might not be inlined.

In C language applications, this option specifies which specific functions the compiler should attempt to inline.


Read syntax diagramSkip visual syntax diagram>>- -Q--+--------------------------+---------------------------><
        |                .-:-----. |
        |  (1)           V       | |
        +--------+- --+----names-+-+
        |        '-+--'            |
        |  (1)                     |

  1. C only

C++ only In the C++ language, the following -Q options apply:

-Q Compiler inlines all functions that it can.
-Q! Compiler does not inline any functions.

C only In the C language, the following -Q options apply:

-Q Attempts to inline all appropriate functions with 20 executable source statements or fewer, subject to the setting of any of the suboptions to the -Q option. If -Q is specified last, all functions are inlined.
-Q! Does not inline any functions. If -Q! is specified last, no functions are inlined.
-Q-names Does not inline functions listed by names. Separate each function name in names with a colon (:). All other appropriate functions are inlined. The option implies -Q.

For example:


causes all functions except those named salary, taxes, expenses, or benefits to be inlined if possible.

A warning message is issued for functions that are not defined in the source file.

-Q+names Attempts to inline the functions listed by names and any other appropriate functions. Each function name in names must be separated by a colon (:). The option implies -Q.

For example,


causes all functions namedfood , clothes, or vacation to be inlined if possible, along with any other functions eligible for inlining.

A warning message is issued for functions that are not defined in the source file or that are defined but cannot be inlined.

This suboption overrides any setting of the threshold value. You can use a threshold value of zero along with -Q+names to inline specific functions. For example:


followed by:


causes only the functions named salary, taxes, or benefits to be inlined, if possible, and no others.

-Q=threshold Sets a size limit on the functions to be inlined. The number of executable statements must be less than or equal to threshold for the function to be inlined. threshold must be a positive integer. The default value is 20. Specifying a threshold value of 0 causes no functions to be inlined except those functions marked with the __inline, _Inline, or _inline keywords.

The threshold value applies to logical C statements. Declarations are not counted, as you can see in the example below:

 int a, b, i;
  for (i=0; i<10; i++) /* statement 1 */ 
     a=i;              /* statement 2 */ 
     b=i;              /* statement 3 */ 


The default is to treat inline specifications as a hint to the compiler. Whether or not inlining occurs may also be dependent on other options that you select:


The -Q option is functionally equivalent to the -qinline option.

If you specify the -g option (to generate debug information), inlining may be affected. See the information for the -g compiler option.

Because inlining does not always improve runtime performance, you should test the effects of this option on your code.

Do not attempt to inline recursive or mutually recursive functions.

Normally, application performance is optimized if you request optimization (-O option), and compiler performance is optimized if you do not request optimization.

The inline, _inline, _Inline, and __inline language keywords override all -Q options except -Q!. The compiler will try to inline functions marked with these keywords regardless of other -Q option settings.

To maximize inlining:


To compile the program myprogram.c so that no functions are inlined, enter:

xlc myprogram.c -O -Q!

To compile the program my_c_program.c so that the compiler attempts to inline functions of fewer than 12 lines, enter:

xlc my_c_program.c -O -Q=12

Related information