Pointer keyword syntax

Technical Note 60385

Targets:
All

Component:
Compiler

Updated:
9/18/2013 4:43 PM

Introduction

Here follows a summary of pointers and their keywords. This information might not be so easy to find in some manuals.

Note

Note that the CONST keyword behaves differently from the other keywords.

CONST keyword formula:

points_to int points_to * pointers_location constptr;

Other keywords formula:

pointers_location int points_to * pointers_location ptrname;

You can only have "pointers location" once for "other keywords".

Examples

Please note that the "keywords" mentioned (__near and __far2) can be any of the IAR Systems memory keywords and that they can be different for different products; for example, far, huge, near, tiny, idata, xdata, pdata, and __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 */

All product names are trademarks or registered trademarks of their respective owners.

Related Tech Notes

© IAR Systems 1995-2016 - All rights reserved.