自己 编译 linux 内核,编译我自己的内核(不是来自linux-kernel源)

我正在关注here的内核教程

我在编译文件时遇到问题.

尝试编译时出现以下错误:

main.c:8: error: expected declaration specifiers or ‘...’ before ‘size_t’

main.c:8: error: conflicting types for ‘memcpy’

./include/system.h:5: note: previous declaration of ‘memcpy’ was here

main.c: In function ‘memcpy’:

main.c:12: error: ‘count’ undeclared (first use in this function)

main.c:12: error: (Each undeclared identifier is reported only once

main.c:12: error: for each function it appears in.)

main.c: At top level:

main.c:16: error: expected declaration specifiers or ‘...’ before ‘size_t’

main.c:16: error: conflicting types for ‘memset’

./include/system.h:6: note: previous declaration of ‘memset’ was here

main.c: In function ‘memset’:

main.c:19: error: ‘count’ undeclared (first use in this function)

main.c: At top level:

main.c:23: error: expected declaration specifiers or ‘...’ before ‘size_t’

main.c:23: error: conflicting types for ‘memsetw’

./include/system.h:7: note: previous declaration of ‘memsetw’ was here

main.c: In function ‘memsetw’:

main.c:26: error: ‘count’ undeclared (first use in this function)

main.c: At top level:

main.c:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘strlen’

main.c:49: warning: return type of ‘main’ is not ‘int’

main.c: In function ‘main’:

main.c:64: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness

./include/system.h:13: note: expected ‘unsigned char *’ but argument is of type ‘char *’

main.c:51: warning: unused variable ‘i’

scrn.c: In function ‘scroll’:

scrn.c:24: warning: passing argument 1 of ‘memcpy’ from incompatible pointer type

./include/system.h:5: note: expected ‘unsigned char *’ but argument is of type ‘short unsigned int *’

scrn.c:24: warning: passing argument 2 of ‘memcpy’ from incompatible pointer type

./include/system.h:5: note: expected ‘const unsigned char *’ but argument is of type ‘short unsigned int *’

scrn.c: In function ‘puts’:

scrn.c:139: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness

./include/system.h:8: note: expected ‘const char *’ but argument is of type ‘unsigned char *’

我的文件是教程中文件的精确副本.

我可以看到在main.c中,函数的定义如下

void * memcpy(void * dest,const void * src,size_t count)

但在我的system.h文件中,它们的定义如下

extern unsigned char * memcpy(unsigned char * dest,const unsigned char * src,int count)

C不是我的主要语言,但我正在学习它,因此,如果我的问题很简单,我会道歉,但我认为这些定义应该相同吗?