gpt4 book ai didi

c - 在 '=' 之前编译 C 代码 : error: expected ',' , ';'、 'asm'、 '__attribute__' 或 'int' 时遇到问题

转载 作者:太空狗 更新时间:2023-10-29 15:01:52 25 4
gpt4 key购买 nike

我正在使用 James M tutorials关于编写内核。我使用 GCC 6.2.0 和 Binutils 在 macOS 10.12 上使用交叉编译器为 elf-i386 arch 编写代码。

main.c 外,一切都可以编译,它因以下错误而失败:

Error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'.

但是,该文件与教程中的完全一样。谁能帮我弄清楚为什么?

/*
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");
}

包含所有内核代码的公共(public)存储库位于:https://gitlab.com/SierraKernel/Core/tree/master

最佳答案

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

关于c - 在 '=' 之前编译 C 代码 : error: expected ',' , ';'、 'asm'、 '__attribute__' 或 'int' 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41499380/

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