Clearing the screen?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Clearing the screen?

Post by gsingh2011 »

Hi, I was wondering what's wrong with this code. It compiles fine, but I get the error - kernel.c:(.text+0x1d): undefined reference to `memset'. I'm assuming it has something to do with including libraries..

Code: Select all

#include <string.h>

// Screen dimensions (for default 80x25 console)
#define LINE_PITCH 160       // line width in bytes
#define LINE_COUNT 25

void clear(volatile unsigned char* videoram)
{
    memset((void*)videoram, 0, LINE_PITCH*LINE_COUNT);
}

void kmain( void* mbd, unsigned int magic )
{
	volatile unsigned char* videoram = (volatile unsigned char *) 0xb8000;
	clear(videoram);
}
User avatar
linuxfood
Member
Member
Posts: 38
Joined: Wed Dec 31, 2008 12:22 am

Re: Clearing the screen?

Post by linuxfood »

Unless you wrote your 'memset', you just made beginner mistake #1.
Don't feel too bad. If you did write your own memset, make sure you're linking with the object file that contains it.

Thanks,

-B
gsingh2011
Member
Member
Posts: 83
Joined: Tue Feb 03, 2009 11:37 am

Re: Clearing the screen?

Post by gsingh2011 »

Ah... I see. Thank you.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Clearing the screen?

Post by Combuster »

#include <string.h>
If that did compile your setup is wrong already. You should not be able to include files that you have not written yourself.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Clearing the screen?

Post by Steve the Pirate »

Combuster wrote:
#include <string.h>
If that did compile your setup is wrong already. You should not be able to include files that you have not written yourself.
That's the reason it did compile - the function is declared in string.h, but he hasn't implemented it, so he gets a linker error instead of a compiler error.
My Site | My Blog
Symmetry - My operating system.
Post Reply