C code compilation failed: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'

I use James M 's core writing tutorials . I am writing cross-compiler code for elf-i386 arch on macOS 10.12 with GCC 6.2.0 and Binutils.

Everything compiles, except main.cthat does not work with this error:

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

However, the file is exactly the same as in the tutorial. Can someone help me understand why?

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

A public repo with all kernel code is available at: https://gitlab.com/SierraKernel/Core/tree/master

+4
3
int main(struct multiboot, *mboot_ptr)

","

int main(struct multiboot *mboot_ptr)
+2

, , , , - , int, os.h, , ; , .

+2

c89 C, . c99 CFLAGS + = -std = c99

0
source

Source: https://habr.com/ru/post/1665956/


All Articles