Intel® C++ Compiler XE 13.1 User and Reference Guides

inline, noinline, forceinline

Specify inlining of all calls in a statement.

Syntax

#pragma inline [recursive]

#pragma forceinline [recursive]

#pragma noinline

Arguments

recursive

indicates that the pragma applies to all of the calls that are called by these calls, recursively, down the call chain

Description

These are statement-specific inlining pragmas. Each can be placed before a C/C++ statement, and will then apply to all of the calls within a statement and all calls within statements nested within that statement.

The forceinline pragma indicates that the calls in question should be inlined whenever the compiler is capable of doing so.

The inline pragma is a hint to the compiler that the user prefers that the calls in question be inlined, but expects the compiler not to inline them if its heuristics determine that the inlining would be overly aggressive and might slow down the compilation of the source code excessively, create too large of an executable, or degrade performance.

The noinline pragma indicates that the calls in question should not be inlined.

These statement-specific pragmas take precedence over the corresponding function-specific pragmas.

Example

The following example uses #pragma forceinline recursive. The #pragma forceinline recursive applies to the call 'sun(a,b)' as well as the call 'fun(a,b)' called inside 'sun(a,b)'.

#include <stdio.h>


static void fun(float a[100][100], float b[100][100])
{
  inti , j;

  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      a[i][j] = 2 * i;
      b[i][j] = 4 * j;
    }
  }
}



static void sun(float a[100][100], float b[100][100])
{
  int i, j;

  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      a[i][j] = 2 * i;
      b[i][j] = 4 * j;
    }
    fun(a, b);
  }
}

static float a[100][100];
static float b[100][100];

extern int main()
{
  int i, j;


  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      a[i][j] = i + j;
      b[i][j] = i - j;
    }
  }
  for (i = 0; i < 99; i++) {
    fun(a, b);
#pragma forceinline recursive
    for (j = 0; j < 99; j++) {
      sun(a, b);
    }
  }
  fprintf(stderr, "%d %d\n", a[99][9], b[99][99]);
}

Submit feedback on this help topic