All of lore.kernel.org
 help / color / mirror / Atom feed
* Compiling C++ kernel module + Makefile
@ 2004-01-16 21:09 Ashish sddf
  2004-01-16 22:07 ` Richard B. Johnson
  2004-01-16 22:40 ` Sam Ravnborg
  0 siblings, 2 replies; 25+ messages in thread
From: Ashish sddf @ 2004-01-16 21:09 UTC (permalink / raw)
  To: linux-kernel

Hi, 
   I am trying to port a C++ kernel module from 2.4 to
2.6. (It is MIT Click Modular Router). 

   As I understand the module building has changed in
ver 2.6. I have got the Makefile to compile it but it
gives me lot of warning - all dependancies problem 

 It appears that the kernel Makefile treats it like a
host application and does not pass the necessary
processing routines.


  Does anyone can ideas about how to change the kernel
makefile to compile the C++ files the same way as C
files ? 


Any help will be appreciated. 


Ashish 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: Compiling C++ kernel module + Makefile
@ 2004-01-19 13:21 Petr Vandrovec
  0 siblings, 0 replies; 25+ messages in thread
From: Petr Vandrovec @ 2004-01-19 13:21 UTC (permalink / raw)
  To: Richard B. Johnson; +Cc: Ashish sddf, linux-kernel, bart

On 19 Jan 04 at 8:46, Richard B. Johnson wrote:
> On Sat, 17 Jan 2004, Bart Samwel wrote:
> 
> > On Friday 16 January 2004 23:07, Richard B. Johnson wrote:
> > > If somebody actually got a module, written in C++, to compile and
> > > work on linux-2.4.nn, as you state, it works only by fiat, i.e., was
> > > declared to work. There is no C++ runtime support in the kernel for
> > > C++. Are you sure this is a module and not an application? Many
> > > network processes (daemons) are applications and they don't require
> > > any knowledge of kernel internals except what's provided by the
> > > normal C/C++ include-files.
> >
> > Rest assured, ;) this is definitely a module. It includes a kernel patch that
> > makes it possible to include a lot of the kernel headers into C++, stuff like
> > changing asm :: to asm : : (note the space, :: is an operator in C++) and
> > renaming "struct namespace" to something containing less C++ keywords. The
> > module also includes rudimentary C++ runtime support code, so that the C++
> > code will run inside the kernel. I'm afraid that the task of compiling it for
> > 2.6 is going to be pretty tough -- the kernel needs loads of patches to make
> > it work within a C++ extern "C" clause, and it probably completely different
> > patches from those needed by 2.4. Getting the build system to work is the
> > least of the concerns.
> >
> > -- Bart
> >
> 
> I can't imagine why anybody would even attempt to write a kernel
> module in C++. Next thing it'll be Visual BASIC, then Java. The
> kernel is written in C and assembly. The tools are provided. It
> can only be arrogance because this whole C v.s. C++ thing was
> hashed-over many times. Somebody apparently wrote something to
> "prove" that it can be done. I'd suggest that you spend some
> time converting it to C if you need that "module". The conversion
> will surely take less time than going through the kernel headers
> looking for "::".

I doubt. I have module which uses templates to get support for
couple of possible userspace interfaces which existed over time,
and it works very well, without any changes to the kernel headers. Only
thing I had to do was:

#ifdef __cplusplus
#  define new new_member
#  define private private_member
#  define namespace namespace_member
#endif

and extern "C" around #includes.

Of course that it is possible to do everything what templates do with
#define, but why do that in complicated ways if it can be done much
simpler?

Of course this module does not use exceptions or rtti, just templates
and static class members.
                                                    
Module compiles on 2.2.0 to 2.6.1, with gcc 2.95-3.4. If you'll limit
yourself to gcc-3.0 or later, you do not have to worry about ::/: : at all,
as gcc's c++ parser gets it right after 2.95.
                                                    Petr Vandrovec


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2004-01-21 17:16 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-16 21:09 Compiling C++ kernel module + Makefile Ashish sddf
2004-01-16 22:07 ` Richard B. Johnson
2004-01-17 12:59   ` Bart Samwel
2004-01-19 13:46     ` Richard B. Johnson
2004-01-19 17:40       ` Bart Samwel
2004-01-19 18:39         ` Richard B. Johnson
2004-01-19 20:02           ` Bart Samwel
2004-01-19 20:37             ` Richard B. Johnson
2004-01-19 21:24               ` Bart Samwel
2004-01-20 15:20                 ` Richard B. Johnson
2004-01-20 17:34                   ` Zan Lynx
2004-01-20 18:10                     ` Richard B. Johnson
2004-01-20 13:38                       ` Thomas Lahoda
2004-01-21  2:24                       ` Michael Clark
2004-01-20 18:16                     ` Chris Friesen
2004-01-21 17:01                 ` Giuliano Pochini
2004-01-21 17:16                   ` Bart Samwel
2004-01-20  0:59               ` Robin Rosenberg
2004-01-20  6:46                 ` Linus Torvalds
2004-01-20  7:32                   ` Robin Rosenberg
2004-01-20 10:46                   ` Bart Samwel
2004-01-20  5:29         ` Valdis.Kletnieks
2004-01-20  9:48           ` Bart Samwel
2004-01-16 22:40 ` Sam Ravnborg
2004-01-19 13:21 Petr Vandrovec

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.