This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

About pointer to a huge table in C

Hi,

I am a bit confused about writing codes with a poitner pointed to a huge table in C with Keil compiler (for C166 MCU).

First if i want to define a pointer pointed to a huge table, naturally i would do:

int huge (*ptable)[256];

However the complier does not allow to write in this way. The only way to pass the compiling is:

int (huge *ptable)[256];

The codes seem to work like this. But i am not really sure if i defined the pointer in a correct way, Can someone confirm me about it?

Second question about type cast. If i want to convert something into a pointer, I found i can do both type casts:

long addr;
int (huge *ptable)[256];

ptable = (int huge (*)[256])(&addr);
ptable = (int (huge *)[256])(&addr);

Both of the 2 lines above seem to work. But i am confused why the complier allows to define a point only in 1 way but allows type cast in 2 different ways? Does anyone knows the story under the hood?

Thanks for the help.

Regards,
Xiang

0