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.
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.
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
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.