无法编译C代码:错误:在“ int”之前应预期为“ =”,“,”,“;”,“ asm”或“ __attribute__”

Jac*_*fer 5 c gcc

我正在使用James M教程编写内核。我在带有GCC 6.2.0和Binutils的macOS 10.12上使用elf-i386拱的交叉编译器编写代码。

除以外 main.c,所有程序都会编译,但会因以下错误而失败:

错误:在'int'之前应为'=',',',';','asm'或'__attribute__'

但是,该文件与教程中的文件完全相同。谁能帮我找出原因?

/*
Sierra Kernel
kernel.c -- Main kernel file
Copyright (C) 2017  Jacobo Soffer <sofferjacob@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>. 
*/

#include <os.h>

int main(struct multiboot *mboot_ptr)
{
    kprint("Welcome to the Sierra Kernel! \n"); // Test VGA Driver
    kprint(BUILD_FULL); // Print version information
    asm volatile ("int $0x3");  // Test interrupts
    asm volatile ("int $0x4");
}
Run Code Online (Sandbox Code Playgroud)

包含所有内核代码的公共仓库可在以下位置获得:https : //gitlab.com/SierraKernel/Core/tree/master

小智 5

可能这是一个迟到的答案,但通常错误指向 int 之前包含的文件中的某些内容不正确,在您的情况下,尝试找出该文件或其包含的任何文件中os.h是否有任何缺失。;


Seb*_*ias 2

int main(struct multiboot, *mboot_ptr)
Run Code Online (Sandbox Code Playgroud)

好像多了一个“,”

尝试

int main(struct multiboot *mboot_ptr)
Run Code Online (Sandbox Code Playgroud)