ポインタキーワードの構文

テクニカル・ノート 60385

アーキテクチャ:

All

コンポーネント:

compiler

更新日:

2018/08/13 8:29

はじめに

ここでは、ポインタとキーワードの概要について説明します。この情報は、マニュアルによっては見つけにくい場合があります。

CONSTキーワードは、他のキーワードとは動作が異なります。

CONSTキーワードの式:

points_to int points_to * pointers_location constptr;

他のキーワードの式:

pointers_location int points_to * pointers_location ptrname;

「他のキーワード」では、「pointers location」(ポインタの場所)は1度しか使用できません。

ここで述べられるキーワード(__nearおよび__far2)は、IAR Systemsのメモリキーワードです。これらのキーワードは、製品によって異なります(far、huge、near、tiny、idata、xdata、pdata、__nearなど)。

/* CONST POINTERS */
const int * c1;
int const * c2;
int * const c3; /* Pointer is a constant pointer */
const int const * c4;
const int * const c5; /* Pointer is a constant pointer */
int const * const c6; /* Pointer is a constant pointer */
const int const * const c7; /* Pointer is a constant pointer */
/* POINTS TO NEAR */
__near int __near * n1; /* Pointer is located in NEAR */
int __near * __near n2; /* Pointer is located in NEAR */
__far2 int __near * n3; /* Pointer is located in FAR2 */
int __near * __far2 n4; /* Pointer is located in FAR2 */
/* POINTS TO FAR2 */
__near int __far2 * f1; /* Pointer is located in NEAR */
int __far2 * __near f2; /* Pointer is located in NEAR */
__far2 int __far2 * f3; /* Pointer is located in FAR2 */
int __far2 * __far2 f4; /* Pointer is located in FAR2 */

全ての製品名は、それぞれの所有者の商標または登録商標です。

申し訳ございませんが、弊社サイトではInternet Explorerをサポートしていません。サイトをより快適にご利用いただくために、Chrome、Edge、Firefoxなどの最新ブラウザをお使いいただきますようお願いいたします。