I am compiling the sample kernel from thes JamesM Tutorial Code. I keep getting the error: kheap.c:11: error: initializer element is not constant
in the line of code below:
Code: Select all
u32int placement_address = (u32int)&end;
Code: Select all
// kheap.c -- Kernel heap functions, also provides
// a placement malloc() for use before the heap is
// initialised.
// Written for JamesM's kernel development tutorials.
#include "kheap.h"
#include "paging.h"
// end is defined in the linker script.
extern u32int end;
u32int placement_address = (u32int)&end;
extern page_directory_t *kernel_directory;
heap_t *kheap=0;
u32int kmalloc_int(u32int sz, int align, u32int *phys)
{
if (kheap != 0)
{
void *addr = alloc(sz, (u8int)align, kheap);
if (phys != 0)
{
page_t *page = get_page((u32int)addr, 0, kernel_directory);
*phys = page->frame*0x1000 + ((u32int)addr&0xFFF);
}
return (u32int)addr;
}
else
{
if (align == 1 && (placement_address & 0xFFFFF000) )
{
// Align the placement address;
placement_address &= 0xFFFFF000;
placement_address += 0x1000;
}
if (phys)
{
*phys = placement_address;
}
u32int tmp = placement_address;
placement_address += sz;
return tmp;
}
}
Thanks,
Joseph