The list.h file in the linux kernel uses the C++ keyword "new" as a name
for a parameter and so the C++ pukes over it. A solution is a #define
new _new infront of the include and #undef new after it like.

#include <rtl_cpp.h>
extern "C" {
        #define new _new
        #include <mbuff.h>
        #undef new
}

I think this was already mentioned on the list a few times, so you might
find other and better solutions in the archives.

- Erwin



crzhang wrote:
> 
> Hi, all
> I add the following :
>     #include <rtl_cpp.h>
>     extern "C" {
>         #include <mbuff.h>
>     }
> in examples/cpp/hello.cpp, when I type make and I get the following:
>     g++ -D__KERNEL__ -Wall -Wstrict-prototypes -fno-strict-aliasing -pipe 
>-mpreferred-stack-boundary=2 -g -D__RTL__ -DMODULE -D_LOOSE_KERNEL_NAMES 
>-I/usr/src/linux/include -I/usr/src/rtl/include -I/usr/src/rtl/include/compat 
>-I/usr/src/rtl/include/posix    -c -o hello.o hello.cpp
> In file included from /usr/src/linux/include/linux/wait.h:13,
>                  from /usr/src/linux/include/linux/fs.h:12,
>                  from /usr/src/rtl/include/mbuff.h:24,
>                  from hello.cpp:4:
> /usr/src/linux/include/linux/list.h:35: parse error before `new'
> /usr/src/linux/include/linux/list.h: In function `void __list_add(...)':
> /usr/src/linux/include/linux/list.h:39: `next' undeclared (first use this function)
> /usr/src/linux/include/linux/list.h:39: (Each undeclared identifier is reported only 
>once
> /usr/src/linux/include/linux/list.h:39: for each function it appears in.)
> /usr/src/linux/include/linux/list.h:39: parse error before `;'
> /usr/src/linux/include/linux/list.h:42: `prev' undeclared (first use this function)
> /usr/src/linux/include/linux/list.h:42: parse error before `;'
> /usr/src/linux/include/linux/list.h: At top level:
> /usr/src/linux/include/linux/list.h:48: parse error before `new'
> /usr/src/linux/include/linux/list.h: In function `void list_add(...)':
> /usr/src/linux/include/linux/list.h:50: parse error before `,'
> /usr/src/linux/include/linux/list.h: At top level:
> /usr/src/linux/include/linux/list.h:56: parse error before `new'
> /usr/src/linux/include/linux/list.h: In function `void list_add_tail(...)':
> /usr/src/linux/include/linux/list.h:58: parse error before `,'
> In file included from /usr/src/linux/include/linux/fs.h:12,
>                  from /usr/src/rtl/include/mbuff.h:24,
>                  from hello.cpp:4:
> /usr/src/linux/include/linux/wait.h: At top level:
> /usr/src/linux/include/linux/wait.h:160: parse error before `new'
> /usr/src/linux/include/linux/wait.h: In function `void __add_wait_queue(...)':
> /usr/src/linux/include/linux/wait.h:163: `head' undeclared (first use this function)
> /usr/src/linux/include/linux/wait.h:163: parse error before `)'
> /usr/src/linux/include/linux/wait.h:164: confused by earlier errors, bailing out
> cpp: output pipe has been closed
> make: *** [hello.o] Error 1
> 
> and the linux kernel is downloaded from 
>ftp://ftp.rlinux.com/pub/rtlinux/v3/rtlinux_kernel_2_4.tar.gz  and
> rtlinux kernel is the final V3
> 
> Can you help me?
> Thanks!
> 
> Wang Heng
> -- [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/rtlinux/
-- [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/rtlinux/

Reply via email to