Keil Logo

C166: POINTER TRUNCATION FOR IDENTICALLY DECLARED POINTERS


Information in this article applies to:

  • C166 All Versions

QUESTION

I compile the following code with the C166:

void main (void)  {

int huge *pTest1, *pTest2;
int huge *pTest3;

pTest1 = pTest3;
pTest2 = pTest3;

}

This generates:

*** WARNING C151: pointer truncation: 'huge' to 'near'.

Why are not all three pointers huge? Why does pTest2 point to near memory?

ANSWER

The memory type specifier huge in a pointer declaration list must be repeated for each pointer.

In your code example, pTest1 points to huge, but pTest2 points to the default memory space (which is near for the memory model Tiny, Small, or Medium).

You may avoid this by using a typedef:

typedef int huge H_INT;

void main (void)  {


H_INT *pTest1, *pTest2;
H_INT *pTest3;

pTest1 = pTest3;
pTest2 = pTest3;

}

Using the typedef, you can be sure that all declarations in the list have the same type.

MORE INFORMATION

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.