Reputation: 135
I'm hoping that someone might be able to explain this to me. I'm writing my own OS, and getting into writing the memory manager. I keep getting a weird warning when I compile my kernel. The warning is quite paradoxical to me. The function is getting the type of parameter it expects, but complaining as if otherwise. Everything runs fine, and I'm able to get the information I need to initialize my memory manager. Can you tell me what's causing this?
$HOME/opt/cross/bin/i686-elf-gcc -c -ffreestanding -O2 -Wall -Wextra -std=gnu99 -ggdb -isystem src/h -o build/kernel.c.o src/c/kernel.c
src/c/kernel.c: In function 'kernel_main': src/c/kernel.c:29:2: warning: passing argument 1 of 'memory_manager_initialize' from incompatible pointer type
memory_manager_initialize(mboot_ptr); // wtf does this cause a warning?
In file included from src/h/system.h:39:0, from src/h/multiboot.h:4, from src/c/kernel.c:1:
src/h/memory.h:35:6: note: expected 'struct multiboot *' but argument is of type 'struct multiboot *'
void memory_manager_initialize(struct multiboot *mboot_ptr);
Here's the code for my loader that GRUB calls.
# Declare constants used for the multiboot header
.set ALIGN, 1<<0
.set MEMINFO, 1<<1
.set MAGIC, 0x1BADB002
.set FLAGS, ALIGN | MEMINFO
.set CHECKSUM, -(MAGIC + FLAGS)
.global .multiboot
.extern code
.extern bss
.extern end
.section .multiboot
#.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.long .multiboot
.long code
.long bss
.long end
.long _start
.section .text
.global _start
.extern kernel_main
.type _start, @function
_start:
push %esp
push %ebx
cli
call kernel_main
.hang:
jmp .hang
.size _start, . - _start
Here's the code from my kernel where the warning is coming from.
int kernel_main(struct multiboot *mboot_ptr, u32int initial_stack)
{
initial_esp = initial_stack;
gdt_initialize();
idt_initialize();
memset((u8int *) &interrupt_handler, 0, sizeof(isr) * 256);
enable_interrupts();
timer_initialize(100);
keyboard_initialize();
keyboard_set_handler(kernel_keyboard_handler);
vga_set_handler(kernel_vga_handler);
memset((u8int *) terminal_buffer, 0, MAX_TERMINAL_BUFFER_SIZE); // clear the terminal buffer (initalize it to 0 when we start running)
// i need to get the memory management going.
memory_manager_initialize(mboot_ptr); // wtf does this cause a warning?
And the function that's being called is defined as
void memory_manager_initialize(struct multiboot *mboot_ptr)
Upvotes: 4
Views: 248
Reputation: 25936
Either your struct is defined as:
typedef struct {
/* Stuff */
} multiboot;
when it should be defined as:
typedef struct multiboot { // Note difference in this line
/* Stuff */
} multiboot;
or your function prototype for memory_manager_initialize()
appears before the compiler sees your definition of struct multiboot
.
Upvotes: 4