[SOLVED] how to access volatile char array through non volatile char pointer

Status
Not open for further replies.

scorrpeio

Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
I have a function whose argument consist of a pointer to unsigned char.

Now, I want to pass an array of type volatile unsigned char. :!:

If I try to pass it directly, compiler doesn't allow me to do so. I think it needs typecasting to be done but I am not sure if it works. :sad:

I am searching about it on the google as well.

Can anyone here tell me what can be the probable way to do this?
 

assuming you have
Code:
volatile unsigned char x[10]={'Z'};
and a function
Code:
void test(unsigned char *ch)
you can try
Code:
    test((unsigned char *) x);
 
That is working.

I initially tried it in reverse way by which, normal pointer was casted to volatile pointer. that is why I did get an error
 

Last edited:
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…