public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* kbuild & C++
@ 2005-09-06 11:23 Budde, Marco
  2005-09-06 11:30 ` Bernd Petrovitsch
                   ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Budde, Marco @ 2005-09-06 11:23 UTC (permalink / raw)
  To: linux-kernel

Hi,

for one of our customers I have to port a Windows driver to
Linux. Large parts of the driver's backend code consists of
C++. 

How can I compile this code with kbuild? The C++ support
(I have tested with 2.6.11) of kbuild seems to be incomplete /
not working.

cu, Marco

Please send me a CC as e-mail.


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: kbuild & C++
@ 2005-09-07  9:13 Budde, Marco
  2005-09-07  9:57 ` Valdis.Kletnieks
  2005-09-07 10:00 ` Bernd Petrovitsch
  0 siblings, 2 replies; 28+ messages in thread
From: Budde, Marco @ 2005-09-07  9:13 UTC (permalink / raw)
  To: Esben Nielsen, Jesper Juhl; +Cc: linux-kernel

Hi,

>> That would be because the kernel is written in *C* (and some asm),
*not* C++.

I cannot see the connection. At the end everything gets converted
to assembler/opcode. In the user space I can mix C and C++ code
without any problems, why should this not be possible in the
kernel mode?

>> There /is/ no C++ support.

This will be a problem in future. Nearly nobody will start a new
larger project (driver, user space software, embedded firmware)
using non OO languages today. So porting eg. Windows drivers to
Linux is nearly impossible without C++ support.

E.g. in my case the Windows source code has got more than 10 MB.
Nobody will convert such an amount of code from C++ to C.
This would take years.

> I think it can only be a plus to Linux to add C++ support for at least
> out-of-mainline drivers. Adding drivers written in C++ into the
mainline
> is another thing.

Right.

cu, Marco


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: kbuild & C++
@ 2005-09-07 10:17 Budde, Marco
  2005-09-07 18:52 ` Lee Revell
  0 siblings, 1 reply; 28+ messages in thread
From: Budde, Marco @ 2005-09-07 10:17 UTC (permalink / raw)
  To: Valdis.Kletnieks; +Cc: linux-kernel

Hi,

> Do you have any *serious* intent to drop 10 *megabytes* worth of
driver
> into the kernel??? (Hint - *everything* in drivers/net/wireless
*totals*
> to only 2.7M).

no, I don't. No every module has to go into the standard kernel :-).

> A Linux device driver isn't the same thing as a Windows device driver
- much of
> a Windows driver is considered "userspace" on Linux, and you're free
to do that
> in C++ if you want.

Well, it is not the first driver I am writing for Linux.
So yes, I do know, what is part of a Linux driver and
what is not.

cu, Marco



^ permalink raw reply	[flat|nested] 28+ messages in thread
[parent not found: <4JJOt-77X-9@gated-at.bofh.it>]
* RE: kbuild & C++
@ 2005-09-07 12:04 Budde, Marco
  2005-09-07 12:58 ` Bernd Petrovitsch
  2005-09-07 13:15 ` Nick Piggin
  0 siblings, 2 replies; 28+ messages in thread
From: Budde, Marco @ 2005-09-07 12:04 UTC (permalink / raw)
  To: Bernd Petrovitsch; +Cc: linux-kernel

Hi,

> Yes, this is a general problem with integrated c/c++ stuff like
> Win-Visual C++. 

not all Windows users do not know what they are doing :-).
Speaking for myself: I am programming under Linux and
Windows (with more than 10 years experience in C and C++)
and I do know the differences. So please do not call
people idiots only because the are writing software under
Windows.

> People think that they can mix it freely, 

They can do.

> in fact they
> are using *only* C++ (it just happens that some part of the source is
> compilable with a C compiler, but since you compile everything with
the
> C++ compiler pressing F9, no one sees the difference).

So if I compile a library with gcc and link the code to a g++
program, the complete program gets compiled with the C++ compiler?
Interesting :-).

> Why do you think are all these "#ifdef _cpluplus" stuff in the header
> files for?

To support mixed code, because otherwise e.g. a C++ compiler cannot
use a library compiled with a C compiler.

> We re on linux-kernel@ here, so we don't care *here* for user-space
> software (only for the interface - i.e. sys-calls).

When you develop a complete product consisting of the embedded
firmware, the driver, and the user space software, you always have
to decide, where to put the code. And in such a case it is really
nice, when you can use the same language in all layers.

> And for embedded usage C++ is unsusable in user-space too since it
will
> ex-bloat the whole software if people simply pull-in usual and/or
common
> C++ libraries like the STL and use them without knowing how much
object
> code they explode with it (if used without thinking).

This applies for all languages. If you do not know, what you are doing,
you can write really awful code. And I cannot agree, that C++ results to
larger code. 

> Which is again wrong. You can OO software without OO languages (though
> you loose some nice features and checking).

If you are an experienced OO programmer, you do not want to use
languages like plain C, because they result into worse code and
make life more difficult. If you do not like any kind of abstraction,
why are you using C instead of pure assembler?

> Is is impossible anyways since the in-kernel interfaces are probably
> quite different (though I don't know anything about ).

A lot of code (backend code) does not need any access to
libraries/interfaces.

> First, how much of it is really the source of a kernel driver (in the
> sense of a Unix/Linux kernel driver)?

At the moment you really need all the code to control all variants of
the hardware. Yes, it is not a good design. We know it, our customer
knows it, but at the moment we have to live with the situation.

> And second, no one expects that you convert your driver source. Just
> write it from scratch 

Can you estimate what such a redesign would cost our customers?
You would need several years to redesign the concept.

cu, Marco


^ permalink raw reply	[flat|nested] 28+ messages in thread
* RE: kbuild & C++
@ 2005-09-15 12:35 Budde, Marco
  2005-09-18 18:41 ` Sam Ravnborg
  0 siblings, 1 reply; 28+ messages in thread
From: Budde, Marco @ 2005-09-15 12:35 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

Hi Sam,

>> How can I compile this code with kbuild? The C++ support
>> (I have tested with 2.6.11) of kbuild seems to be incomplete /
>> not working.
> Since you did not send any sample code shall I assume this was not a
> serious request?

it is of course a serious request.

At the moment we are using some additional rules for kbuild.
They have worked for a previous project of our customer and I
hope they will work for this project, too.

-------------------------------------------------------------------

include $(SRC_ROOT)comps/Kbuild.includes

EXTRA_CPPFLAGS += -fno-exceptions -fno-rtti \
                  $(INCLUDE_DIRS)
EXTRA_CFLAGS += $(INCLUDE_DIRS)


%.o: %.cpp FORCE
	$(call cmd,force_checksrc)
	$(call if_changed_rule,cc_o_cpp)


quiet_cmd_cc_o_cpp = C++ $(quiet_modtag)  $@


ifndef CONFIG_MODVERSIONS
cmd_cc_o_cpp = $(CXX) $(cpp_flags) -c -o $@ $<
else
cmd_cc_o_cpp = $(CXX) $(cpp_flags) -c -o $(@D)/.tmp_$(@F) $<
endif



define rule_cc_o_cpp
        $(if $($(quiet)cmd_checksrc),echo '  $($(quiet)cmd_checksrc)';)
\
        $(cmd_checksrc)
\
        $(if $($(quiet)cmd_cc_o_cpp),echo '  $($(quiet)cmd_cc_o_cpp)';)
\
        $(cmd_cc_o_cpp);
\
        $(cmd_modversions)
\
        scripts/basic/fixdep $(depfile) $@ '$(cmd_cc_o_cpp)' >
$(@D)/.$(@F).tmp;  \
        rm -f $(depfile);
\
        mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
endef

-------------------------------------------------------------------



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

end of thread, other threads:[~2005-09-18 18:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-06 11:23 kbuild & C++ Budde, Marco
2005-09-06 11:30 ` Bernd Petrovitsch
2005-09-06 21:08   ` Chris Frey
2005-09-07  6:39     ` Bernd Petrovitsch
2005-09-06 11:38 ` linux-os (Dick Johnson)
2005-09-06 21:20 ` Jesper Juhl
2005-09-06 22:20   ` Esben Nielsen
2005-09-06 22:22     ` Randy.Dunlap
2005-09-06 22:32     ` Jesper Juhl
2005-09-07  2:33     ` Valdis.Kletnieks
2005-09-07  9:21       ` Esben Nielsen
2005-09-07 10:11         ` Valdis.Kletnieks
2005-09-07 10:58           ` Esben Nielsen
2005-09-07 11:44         ` Bernd Petrovitsch
2005-09-06 21:41 ` Sam Ravnborg
2005-09-10 12:29 ` Sam Ravnborg
  -- strict thread matches above, loose matches on Subject: below --
2005-09-07  9:13 Budde, Marco
2005-09-07  9:57 ` Valdis.Kletnieks
2005-09-07 10:45   ` Esben Nielsen
2005-09-07 10:00 ` Bernd Petrovitsch
2005-09-07 10:17 Budde, Marco
2005-09-07 18:52 ` Lee Revell
     [not found] <4JJOt-77X-9@gated-at.bofh.it>
2005-09-07 12:02 ` Bodo Eggert
2005-09-07 12:04 Budde, Marco
2005-09-07 12:58 ` Bernd Petrovitsch
2005-09-07 13:15 ` Nick Piggin
2005-09-15 12:35 Budde, Marco
2005-09-18 18:41 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox