If the file /usr/src/linux-headers-2.6.28-11-generic/include/linux/slab.h or /usr/include/linux/slab.h exist, the error can be a bug in gcc/cpp, which is unprobable. Thus please check if one of the above files really exists and is readable.
I do not understand the meaning of your program. kmalloc() is a kernel function that is not available in userspace (it allocates kernel memory). An equivalent replacement is the function malloc() from malloc.h
If you want to write a kernel module, then using a main() function is the wrong way to start with. In this case you should use:
Code:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
static int __init mymod_init(void)
{
void * ptr = kmalloc(1024,GPF_KERNEL);
printk(KERN_INFO "kernel memory at %p\n", ptr);
kfree(ptr);
return 0;
}
module_init(mymod_init);