次の方法で共有


__restrict

restrict __declspec の修飾子と同様に__restrict のキーワードシンボルが現在のスコープにエイリアスが設定されていないことを示します。__restrict のキーワードは restrict __declspec の修飾子と次の点で異なります。:

  • __restrict のキーワードは変数にのみ有効です __declspec(restrict)関数宣言と定義内でのみ有効です。

  • __restrict を使用するとコンパイラは変数の非エイリアスのプロパティは反映されません。つまり__restrict の非 __restrict の変数を変数に代入される場合コンパイラは変数が非 __restrict のエイリアスが設定されていないことを示します。これは C99 固有の restrict キーワードの動作とは異なります。

通常関数全体の動作に影響を及ぼす場合__declspec はキーワードを使用することをお勧めします。

__restrict は C99 固有の restrict に似ていますが__restrict はC++ または C プログラムで使用できます。

C++ の参照の __restrict のサポートはありません。 

[!メモ]

または 揮発性 (C++) のキーワードを持つ変数で使用する場合volatile が優先されます。

使用例

// __restrict_keyword.c
// compile with: /LD
// In the following function, declare a and b as disjoint arrays
// but do not have same assurance for c and d.
void sum2(int n, int * __restrict a, int * __restrict b, 
          int * c, int * d) {
   int i;
   for (i = 0; i < n; i++) {
      a[i] = b[i] + c[i];
      c[i] = b[i] + d[i];
    }
}

// By marking union members as __restrict, tell compiler that
// only z.x or z.y will be accessed in any given scope.
union z {
   int * __restrict x;
   double * __restrict y;
};

参照

関連項目

C++ のキーワード