Miscellaneous > Programming & Networking
Casting with pointers?
(1/1)
anphanax:
First off, let me explain what i'm doing. I'm accessing VRAM (The VGA/EGA Offset) in a 320x200, 256 color environment. (Not that annoying 4-layer crap)
/* This Works */
unsigned char far *videoRAM = (unsigned char far *)0xA0000000L;
/* This Doesn't:
ERROR: Cannot convert 'unsigned long' to
'unsigned char*' */
unsigned char far *videoRAM = 0xA0000000L;
Why do I need casting on memory locations?
It's a location in memory, and has nothing
really todo with the datatype, so i'm a bit
confused.
I posted this here because I tried getting an answer in a "computer" chat and no one seemed to know what I was talking about.
[ December 17, 2003: Message edited by: anphanax ]
Refalm:
quote:anphanax: Why do I need casting on memory locations? It's a location in memory, and has nothing really todo with the datatype, so i'm a bit confused.
--- End quote ---
Are you talking about the BIOS or the RAM? I'm confused now too :confused:
flap:
It's just standard type-checking practice, and it depends on the compiler you're using. GCC (which I assume you're not using) would let you do it without a cast but would give you a warning.
anphanax:
Thanks for your help.
Navigation
[0] Message Index
Go to full version