Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Re: Re: [OT] C++ coding

Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
>titled "c++ tutoring for Maxim et al". It simply fixes Maxim's code where he illustrated exceptions

Just plain and simple: C++ exceptions are a defunct toy without RAII.

I know lots of C++ developers (myself included :-) I was a COM guy in late 1990ies) and teams. Among them, not more then 10% really go the "heavy proper use of RAII" way. Others consider RAII as distasteful, due to a) lots of non-product-feature-carrying code to write b) no explicit points of destruction, not so important for memory and handles but very important for locks.

And, surely, these RAII-non-users do not use C++ exceptions. Mostly, they use the same language subset that COM uses (even if they do not use COM itself, they usually have their analog of COM - i.e. QI and refcounts - for UNIXen and such).

Also note that proper support of "auto/shared/unique" RAII refs requires rvalue ref support in language syntax (unless you want to have a dramatic perf hit), and this is a very new and recent thing. For MS's compiler, this is VC++ 2010.

It is good if the object itself has a refcount inside it, like the COM one. In this case, you can only use shared-kind of RAII refs (like the MS's _com_ptr_t) and relax. Worse if the object has no such thing, like the handle or the allocated memory pointer.

Maxim S. Shatskih
Windows DDK MVP
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA