Page 2 of 2

Re: C++ Bare Bones kmain.cpp Error

Posted: Sat Jan 12, 2013 10:56 am
by jpal
Use this code:
#include <stdint.h>

using namespace std;

extern "C" uint32_t magic;
extern "C" void *mbd;

extern "C" void kmain(void)
{


if ( magic != 0x2BADB002 )
{
/* Something went not according to specs. Print an error */
/* message and halt, but do *not* rely on the multiboot */
/* data structure. */
}

/* You could either use multiboot.h */
/* (http://www.gnu.org/software/grub/manual ... boot_002eh) */
/* or do your offsets yourself. The following is merely an example. */
//char * boot_loader_name =(char*) ((long*)mbd)[16];

/* Print a letter to screen to see everything is working: */
unsigned char *videoram = (unsigned char *) 0xb8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* light grey (7) on black (0). */
}

Re: C++ Bare Bones kmain.cpp Error

Posted: Sat Jan 12, 2013 11:01 am
by Griwes

Code: Select all

using namespace std;
Do you always use code you don't understand? Because presence of this line in your code proves you have no idea what it does.

It's funny how many people in the world put that line in their code without thinking about it or even knowing what it does... well, less funny when problems arise because of this.

Re: C++ Bare Bones kmain.cpp Error

Posted: Fri Jan 18, 2013 3:54 am
by BMW
cxzuk wrote:I believe the argument is that the wiki should not provide a copy&paste operating system, but provide descriptions of theories, designs and structures.

Whether thats a good goal for the wiki, or if the errorsome code hinders learning of these? Im not sure.
I certainly don't call the bare bones tutorial an "operating system". All it does is print "A" on the screen. If someone wants to copy&paste it, its not much use until they develop it further.

I think the tutorial should definitely work if people follow the instructions. Especially since it is such a simple tutorial. Making a purposeful error in a tutorial will just cause people to post posts saying "The tutorial doesn't work!!!".