This is a very well known problem, and seen by quite a few ppl trying to use
C++ in the linux kernel. Not only the linkage is important but also the fact
that the linux kernel uses several names that are keywords in C++, for example
new (like in this case). The only solution is not to inlcude kernel headers in
C++ source files (also not indirectly). To use C functions from the kernel or
RTL you will have to redefine them in a separate header file with only the
prototypes. If the function for example needs a pointer of a certain type ,
like RT_TASK* or so you will have to fake those.
Pierre Cloutier and myself made a start for things like that in RTAI but
almost had to duplicate all RTAI prototypes, we hope that we can make the use
of C++ and LXRT (which had the same problem) easier in the next major version
of RTAI, but that won't solve your problem with RTL.
You might be able to find a C++ module i mail to the RTAI list in the list
archive, maybe that will help you a bit.
- Erwin
Ivan Martinez wrote:
>
> That doesn't make any difference, I get exactly the same errors :-(
>
> On Monday 12 November 2001 12:59, David Olofson wrote:
> > On Monday 12 November 2001 10:45, Ivan Martinez wrote:
> > > Including rtl_posixio.h in the very first line causes:
> > >
> > > In file included from
> > > /usr/src/rtlinux-3.1/linux/include/linux/wait.h:14, from
> > > /usr/src/rtlinux-3.1/linux/include/linux/fs.h:12, from
> > > /usr/src/rtlinux-3.1/include/rtl_posixio.h:13, from rtmodule.cpp:1:
> > > /usr/src/rtlinux-3.1/linux/include/linux/list.h:35: parse error before
> > > `new' /usr/src/rtlinux-3.1/linux/include/linux/list.h: In function
> > > `void __list_add (...)':
> > > /usr/src/rtlinux-3.1/linux/include/linux/list.h:39: `next' undeclared
> > > (first use this function)
> > > /usr/src/rtlinux-3.1/linux/include/linux/list.h:39: (Each undeclared
> > > identifier is reported only once
> >
> > Ok; those headers aren't written for C++, so you have to tell the
> > compiler explicitly to treat them like C code;
> >
> > extern "C" {
> > #include <various C headers>
> > }
> >
> > That goes for all kernel headers actually. C++ compilers usually generate
> > different symbol names for the same code and various other linkage
> > differences, so you'll get either unresolved symbols or nasty bugs if you
> > don't tell the compiler what to do.
> >
> >
> > //David Olofson --- Programmer, Reologica Instruments AB
> >
> > .- M A I A -------------------------------------------------.
> >
> > | Multimedia Application Integration Architecture |
> > | A Free/Open Source Plugin API for Professional Multimedia |
> >
> > `----------------------------> http://www.linuxdj.com/maia -'
> > .- David Olofson -------------------------------------------.
> >
> > | Audio Hacker - Open Source Advocate - Singer - Songwriter |
> >
> > `-------------------------------------> http://olofson.net -'
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/