Girish Pattabiraman wrote: > MSDN has this article about risks of using C++ in drivers - > http://msdn.microsoft.com/en-us/windows/hardware/gg487420.aspx > > But PortCls drivers, especially audio drivers are C++ by default. > > Why have they taken such a cowardly approach in the article? They have taken the SAFE approach. That approach is safer than trying to describe exactly which features of the C++ compiler are not workable in kernel mode. > Either they should declare explicitly that C++ is not allowed, or they > should provide full support for C++. If this were a perfect world, they would. But, alas, it isn't. AVStream drivers are also C++. Heck, KMDF is in C++. > I don't like the words "might", "maybe", etc. in documentation. > Computer science is an exact science in which everything should be > clearly defined. > > The author mentions reading the output of the compiler (assembly) > carefully, is he really being serious about it?? > Does he really expect us to go through assembly output of the compiler? > I'm not super-human and cannot (infact refuse) to go through compiler > generated assembly of everything I have written. That's fine. Then write your drivers in C. It is possible to enumerate a list of the C++ features that cannot be used in KM, and it is a relatively small list (I disagree with Larry here). Exceptions are a big problem, and that throws out the normal STL (although there are exception-free implementations available). The biggest problem is compiler-generated code. MSVC does not provide a mechanism for me to direct into which COFF section compiler-generated code should be placed. That means I can't guarantee whether such code will be placed in pagable memory or not. That throws out templates and compiler-generated constructors and destructors. That risk can be ameliorated, in the worst case be making the whole driver non-paged. It is also possible to reverse-engineer the rule that the compiler uses, but that's unsupported. It's up to you to decide whether the risk is tolerable or not. If it's not tolerable, write your driver in C. Just that easy. > Has anyone ever encountered a crash due to using C++ in WDM drivers? Not I, but I know what buttons should not be pushed. -- Tim Roberts, timr@xxxxxxxxx Providenza & Boekelheide, Inc. ****************** WDMAUDIODEV addresses: Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx Subscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe Unsubscribe: mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe Moderator: mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx URL to WDMAUDIODEV page: http://www.wdmaudiodev.com/