Kneemeyer, Ralf <ralf_kneemeyer@digi.com> wrote:
> Question:
> Is there any hint to get c++ sources running in kernel
> or kernel modules ?
> In my tests I wasn't even able to insmod a simple module
> without c++ source, just with g++ compiled ( source.cc ).
It's actually pretty easy - just make sure to link in the following
code, which puts in the minimal runtime for C++. Proper exception
handling is left as an exercise to the reader...
Also, you may need to do an extern "C" {}; block for some headers,
and at least in the 2.3.x code series some headers have structure
members named ``new''.
----------- cut here - cppfake.cpp ----------------------
#include <linux/kernel.h>
#include <linux/types.h>
extern "C" {
void perror(char *wrt) { printk(KERN_ERR ": %s\n",wrt); }
void __throw() { panic("C++ Exception thrown!"); }
void __rtti_user(void) {}
void __rtti_si(void) {}
}; // extern "C"
void terminate (void) {}
void operator delete/**/(void *ptr)
{
if (ptr)
kfree(ptr);
}
void operator delete[](void *ptr)
{
if (ptr)
kfree(ptr);
}
void *operator new(size_t sz)
{
return kalloc(sz,GFP_KERNEL);
}
void *operator new[](size_t sz)
{
return kalloc(sz,GFP_KERNEL);
}
------------------- cut here -----------
-- Jason McMullan, Senior Linux Consultant, Linuxcare, Inc. 412.422.8077 tel, 415.701.0792 fax jmcmullan@linuxcare.com, http://www.linuxcare.com/ Linuxcare. Support for the revolution.- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:36 EST