From: Giovanni Dicanio on
"Tom Serface" <tom(a)camaswood.com> ha scritto nel messaggio
news:#dGCWmmmKHA.5568(a)TK2MSFTNGP02.phx.gbl...

> Several people have already answered your question, but I just wanted to
> add that I don't see any particular reason to use vanilla "C" any longer.

Device driver programming in kernel mode? :)

G


From: Tom Serface on
Yeah, there's always something. I've never done device drivers, but I bet
you could still do them in C++ somehow.

Tom

"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message
news:ejvNdhnmKHA.3128(a)TK2MSFTNGP02.phx.gbl...
> "Tom Serface" <tom(a)camaswood.com> ha scritto nel messaggio
> news:#dGCWmmmKHA.5568(a)TK2MSFTNGP02.phx.gbl...
>
>> Several people have already answered your question, but I just wanted to
>> add that I don't see any particular reason to use vanilla "C" any longer.
>
> Device driver programming in kernel mode? :)
>
> G
>
>
From: Giovanni Dicanio on
"Tom Serface" <tom(a)camaswood.com> ha scritto nel messaggio
news:uMCoo2qmKHA.5520(a)TK2MSFTNGP06.phx.gbl...

> I've never done device drivers, but I bet you could still do them in C++
> somehow.

http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx

However we can wait for Joe, who teaches device driver courses and has lots
of experience in this fascinating field.

Giovanni



From: WJ on
The reason I'm still using C file is it is ported from the firmware and it is
a lot troulbe to compile it as C++. Thanks.

WJ

"Tom Serface" wrote:

> Several people have already answered your question, but I just wanted to add
> that I don't see any particular reason to use vanilla "C" any longer. Any
> platform that can support C would certainly support C++ these days and
> almost all of the C++ compilers support templates in one form or another.
>
> Unless you need something specific for calling convention, I wouldn't use C
> at all. That gets rid of the confusion.
>
> Tom
>
> "WJ" <WJ(a)discussions.microsoft.com> wrote in message
> news:84083384-1716-4788-B3B5-1E564791DB57(a)microsoft.com...
> > can "template" be used in .C file?
> >
> > I wanted to write a arameterized function, but "template" would not
> > compile.
> > I am thinking that the template keyword is not supported in .C file, but I
> > just want to confirm.
> >
> > Thanks.
> >
> > WJ
>
> .
>
From: Joseph M. Newcomer on
C++ in the kernel has serious problems. Not intrinsic problems, but serious problems.
When I was at a Driver DevCon some years ago, I asked "Isn't it about time we should be
able to use C++ in the kernel?" and was dragged over to one of the C++ compiler leads. We
talked (or rather, I listened) for about half an hour to everything that can go wrong in
the kernel. Only a subset of C++ actually works. His comment was that he could make it
work in the kernel, but it involved some significant compiler changes (most of them
#pragmas, and the consequent handling of them). The problem was simply that there was no
development budget for this. So it wasn't impossible, just a Very Bad Idea. After 30
minutes of hearing all the things that could go wrong, in great detail, I walked away with
one bit set: "Don't use C++ in the kernel".

There is an infamous white paper on why C++ in the kernel produces problems. I haven't
bothered to track it down, but it was someone's analysis of the problems.

The class of drivers known as "multimedia streaming drivers" are written in C++, and the
paper came from someone's analysis of all the things that had gone wrong once programmers
outside Microsoft (who didn't have the top-secret internal memos that said what did and
didn't work) started writing these drivers. Apparently it is a real nightmare. I've
never even looked at writing them.

That said, I've heard from other sources that the KMDF framework is written in C++, but in
a very, very carefully selected subset of C++ that is known to work correctly. I have no
data to confirm or refute this claim, which was made to me by someone outside Microsoft.

Actually, Peter Viscarola (OSR, the premier driver writers in the country, possibly the
world) once asked "Why can't we write drivers in C#?" in one of his "Peter Pontificates"
columns in the OSR newsletter. A firestorm erupted, with people claiming that you
couldn't write efficient code in C#, that C was good enough for their grandpa and, by gum,
it's good enough for me, and that anyone who didn't want to code in C was clearly
delusional. But I agree with Peter: kernel code is too important to leave it to C
programmers.

I just finished a large C project based on the fact that the customer base for the client
was still programming in C. One of the things I produced was an MFC-compatible wrapper so
I could write all my code in C++, and not have to write anything in C.
joe
On Thu, 21 Jan 2010 16:40:14 +0100, "Giovanni Dicanio"
<giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote:

>"Tom Serface" <tom(a)camaswood.com> ha scritto nel messaggio
>news:uMCoo2qmKHA.5520(a)TK2MSFTNGP06.phx.gbl...
>
>> I've never done device drivers, but I bet you could still do them in C++
>> somehow.
>
>http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx
>
>However we can wait for Joe, who teaches device driver courses and has lots
>of experience in this fascinating field.
>
>Giovanni
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm