【发布时间】:2017-05-20 20:14:06
【问题描述】:
我在编写内核时使用James M tutorials。我在 macOS 10.12 上使用带有 GCC 6.2.0 和 Binutils 的 elf-i386 架构的交叉编译器编写代码。
一切都编译除了 main.c,失败并出现此错误:
错误:之前应为 '='、','、';'、'asm' 或 '__attribute__' '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");
}
包含所有内核代码的公共存储库位于:https://gitlab.com/SierraKernel/Core/tree/master
【问题讨论】:
-
你好像多了一个逗号:
int main(struct multiboot *mboot_ptr) -
请注意,您需要仔细考虑
main()的高度非标准的struct multiboot *参数将来自何处。您必须在嵌入式系统上工作,但是如果您正在编写内核,那么将如何初始化并将该结构传递给内核?