device driver

T

Tom

Guest
Hi,

when trying to access the data register of a device I must first
perform a cast on the register address:

example:

int * data_register = (int *) 0xFFFF0000;

Can somebody explain me why the cast is needed ?

Thx,

T.
 
when trying to access the data register of a device I must first
perform a cast on the register address:

example:

int * data_register = (int *) 0xFFFF0000;

Can somebody explain me why the cast is needed ?
Find a friendly software geek and get them to give you a lesson
in type checking.

Assuming
int x;

Roughly, it's so the compiler knows that data_register is a pointer
to an int rather than an int. So you need to write
x = *data_register
rather than
x = data_register

Having the compiler check for that sort of mixup catches a
huge fraction of simple programming bugs. (They are often
a pain to track down with traditional debugging methods.)

--
The suespammers.org mail server is located in California. So are all my
other mailboxes. Please do not send unsolicited bulk e-mail or unsolicited
commercial e-mail to my suespammers.org address or any of my other addresses.
These are my opinions, not necessarily my employer's. I hate spam.
 

Welcome to EDABoard.com

Sponsor

Back
Top