LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Joonwoo Park" <joonwpark81@gmail.com>
To: "Jan Engelhardt" <jengelh@computergmbh.de>
Cc: "rohit h" <hrohit85@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [LINUX-KERNEL] C++ in linux kernel
Date: Sat, 9 Feb 2008 09:45:26 +0900	[thread overview]
Message-ID: <b25c3fa70802081645p6aad3883s6d1b5e169b3cd091@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0802081653560.26116@fbirervta.pbzchgretzou.qr>

2008/2/9, Jan Engelhardt <jengelh@computergmbh.de>:
>
> On Feb 9 2008 00:14, Joonwoo Park wrote:
> >2008/2/8, rohit h <hrohit85@gmail.com>:
> >> Hi,
> >>  I am a kernel newbie.
> >>  I tried to insmod a C++ module containing classes, inheritance.
> >>  I am getting 'unresolved symbol' error when I use the 'new' keyword.
> >>  What could the problem be?
> >>
> >>  What kind of runtime support is needed ( arm linux kernel)? Is a
> >> patch available for it?
> >>
> >Please take a look at click modular router which is using c++ as a
> >linux kernel module.
> >http://www.read.cs.ucla.edu/click/
> >The lib/glue.cc provides custom operator new.
>
> Uh, let's not make the world worse :)
> Just call malloc from C++, and carefully select what C++ features
> you are going to use. The VMware source for example does it right.
>

Yep, also I think that if kmalloc is possible it would better than the
operator new.

Rohit,
Compiling the kernel module with g++ is not a simple work, you may
need big patch for kernel itself.
The c++ has more internal keywords than c.
e.g) new, delete, and ::
The new and delete should be re-spelled with another names.
The '::' is used in inline assembly however in c++ it means global namespace.

In conclusion, I don't recommand c++ for linux kernel without very
special goal like the click project :)

Joonwoo

  reply	other threads:[~2008-02-09  0:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08  5:21 rohit h
2008-02-08  5:28 ` KOSAKI Motohiro
2008-02-08 10:17 ` [LINUX-KERNEL] " Bernd Petrovitsch
2008-02-08 13:39 ` Andi Kleen
2008-02-08 15:14 ` [LINUX-KERNEL] " Joonwoo Park
2008-02-08 15:54   ` Jan Engelhardt
2008-02-09  0:45     ` Joonwoo Park [this message]
2008-02-11 11:37     ` rohit h
2008-02-11 11:49       ` vignesh babu bm
2008-02-11 12:20       ` Bernd Petrovitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b25c3fa70802081645p6aad3883s6d1b5e169b3cd091@mail.gmail.com \
    --to=joonwpark81@gmail.com \
    --cc=hrohit85@gmail.com \
    --cc=jengelh@computergmbh.de \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [LINUX-KERNEL] C++ in linux kernel' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).