kern/99979: Get Ready for Kernel Module in C++

Dag-Erling Smørgrav des at des.no
Tue Jul 11 11:19:26 UTC 2006


mag at intron.ac writes:
> But "-ffreestanding" doesn't work with C++.

While the C++ standard does define hosted and freestanding
implementations, its definition is different from (and less useful
than) that in the C standard.  For instance, the C++ standard requires
the existence of abort(), atexit() and exit() even in a freestanding
implementation.

Basically, one cannot indiscriminately use the same compiler flags for
C and C++, because they are very different languages - far more
different than they seem on the surface.  Modern C++ is very poorly
suited for low-level code.

> According to above explanation, "-fno-builtin" is a subset of
> "-ffreestanding" and it's enough for kernel.

No, it isn't.  I think you would do wisely to acquire a little more
knowledge of and experience with C, C++ and kernel programming before
you pursue this topic any further.

Most importantly, we already have an working object model in the
FreeBSD kernel, with classes, inheritance, and all that jazz,
implemented partly in C and partly in a custom IDL which is translated
into C by src/sys/tools/makeobjops.awk.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list