gpt4 book ai didi

c++ - kernel.cpp 在制作 kernel.o 时显示错误和 Makefile 错误

转载 作者:太空宇宙 更新时间:2023-11-04 09:17:36 27 4
gpt4 key购买 nike

<分区>

错误是:(我理解警告,请更正错误)

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com