错误是:(我理解警告,请纠正错误)
root@kali:~/Desktop/Ohm Os# make kernel.o
g++ -m32 -o kernel.o -c kernel.cpp
kernel.cpp: In function ‘void kernelMain(void*, unsigned int)’:
kernel.cpp:27:25: warning: ISO C++ forbids converting a string constant to
‘char*’ [-Wwrite-strings]
printf("HELLO WORLD");
^
kernel.cpp:31:1: error: expected primary-expression before ‘}’ token
}
^
Makefile:9: recipe for target 'kernel.o' failed
make: *** [kernel.o] Error 1
这是我的KERNEL.CPP:
void printf(char* str)
{
unsigned short* VideoMemory = (unsigned short*)0xb8000;
for(int i = 0; str[i] != '\0'; ++i)
VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];
}
void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
printf("HELLO WORLD");
while(1)
}
还有我的Makefile:
GPPPARAMS = -m32
ASPARAMS = --32
LDPARAMS = -melf_i386
ojects = loader.o kernel.o
%.o: %.cpp
g++ $(GPPPARAMS) -o $@ -c $<
%.o: %.s
as $(ASPARAMS) -o $@ $<
mykernel.bin: linker.ld $(objects)
ld $(LDPARAMS) -T $< -o $@ $(objects)
install: mykernel.bin
sudo cp $< /boot/mykernel.bin