954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

implicit casting

I am getting a casting error with:

page_directory[0] = page_table;


where

unsigned long *page_directory = (unsigned long *) 0x9C000;
unsigned long *page_table = (unsigned long *) 0x9D000;


Note that this is to initialize paging at kernel level, so stdlib.h is NOT an option, as malloc() -- a memory allocation function -- is to be part of the memory manager this calls. how would I explicitly type-cast that?

SphinCorp
Newbie Poster
3 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

Well, what's the type of page_directory[0]? page_directory is a pointer to unsigned long, right? So after an offset and dereference you'd be looking at an unsigned long, thus:

page_directory[0] = (unsigned long)page_table;

That will make your error go away.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You