我在編寫內核時使用James M tutorials。我使用GCC 6.2.0和Binutils在MacOS 10.12上爲elf-i386 arch編寫了一個交叉編譯器的代碼。無法編譯C代碼:錯誤:在'int'之前預計'=',',';','asm'或'__attribute__'
一切編譯除了main.c
,它失敗,此錯誤:
Error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'.
但是,該文件是完全一樣的教程。任何人都可以幫我弄清楚爲什麼?
/*
Sierra Kernel
kernel.c -- Main kernel file
Copyright (C) 2017 Jacobo Soffer <[email protected]>
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)' –
請注意,您需要仔細考慮高度不標準的'結構multiboot *'參數'main()'將來自於。您必須在嵌入式系統上工作,但是如果您正在編寫內核,那麼將會如何初始化並將該結構傳遞給內核? –