Browse by Tags
All Tags »
C++ (
RSS)
This is a bug Dima encountered several months ago, and I’ve been looking for an opportunity to document ever since. tl;dr – when unmanaged C++ code throws an exception which propagates through an interop boundary to managed code, C++ destructors are not called. To fix, don’t allow C++ exception propagation outside module boundaries, or compile with /EHa. It was recorded before on this StackOverflow thread , where the conclusion is that “ the CLR hooks into SEH handling to catch native exceptions...
Noam and I delivered on Tuesday a joint session called Everything New in C++ at the SELA Developer Practice . It’s been a really fun session to work on, even though it was also a cold reminder how easy it is to forget “The C++ Way” when you stay away for a little while. The new C++ standard is not just a set of minor additions to the C++ language and libraries—it almost feels like a whole new language, what with the lambda functions, type inference, and rich concurrency libraries. While we were planning...
The C++ compiler in Visual Studio 11 has another neat optimization feature up its sleeve. Unlike intrusive features, such as running code on the GPU using the AMP extensions, this one requires no additional compilation switches and no changes – even the slightest – to the code. The new compiler will use SIMD ( Single Instruction Multiple Data ) instructions from the SSE/SSE2 and AVX family to "parallelize" loops. This is not the standard, thread-level parallelism, which runs certain iterations...
Executive summary: When using the Windows debugger engine to debug optimized C++ code compiled with Visual Studio 11 you can step into inline functions and see local variables that are stored in CPU registers. The current (Visual Studio 2010 compiler) state of affairs is that compiler optimizations are way smarter than the debugger engine, which lacks the information necessary to map a fully optimized binary back to the source code in a reliable manner. This is why C++ developers don’t like debugging...
The WinRT type system relies strongly on WinRT components, which are COM objects implementing a specific set of interfaces and adhering to a certain ABI (Application Binary Interface). We will examine here this ABI and how C++ compiler extensions help reference that ABI without exposing the nitty-gritty details of dealing with COM interfaces and COM activation. A WinRT component implements the IInspectable interface , which derives from IUnknown (however, WinRT components do not have dual interfaces...
During the last couple of months, I have been updating the materials of the Developing Windows Concurrent Applications course. It is now an up-to-date four day ILT with lots of labs, demos, design patterns, and other practical materials to help C++ developers write their next great concurrent application for Windows. The target audience is C++ programmers with 1-2 years of experience writing Windows applications, but who haven’t necessarily seen how to create threads, queue work to the thread pool...
I’m keeping up with the updates from the SELA Developer Days conference. Yesterday our classes were full to the brim with attendees – some of the sessions delivered were Parallel Programming in .NET 4.0 , Introduction to Windows Phone 7 , and a feature-packed day on TFS 2010 and Visual Studio 2010 . I delivered yesterday a session on C++ debugging , in which we covered the following topics: How to read x86 and x64 assembly listings created by the C/C++ compilers How to match debugging symbols to...
The following is a summary of tools and resources that you might be interested in after taking the .NET Debugging and/or C++ Debugging courses we offer at Sela. [Shameless plug: If you haven’t taken these courses yet, I strongly suggest that you check them out. Between the two of them they have more than 20 hands-on debugging exercises which basically guarantee that you’re going to come out a WinDbg expert and be able to analyze dumps, solve problems in production, pinpoint memory leaks, and so on...
A few days ago I demonstrated a debugging scenario where one thread attempts to call a virtual function on an object whose destructor is running on another thread . The base destructor restores the virtual function table to that of the base class, which causes the other thread to call a pure virtual function. The code that I used to reproduce this scenario is really simple, but it’s not (at least for me :-)) immediately evident from reading it that this bug is lurking in the shadows. Here’s the code...
How badly, on a scale of 1 to 10, do you like this error message? Not the friendliest one to see, I bet, when you’re trying to make your way through a day without calling any pure virtual functions… Well, a pure virtual function call is not a rare thing to see in the C++ world, and there are numerous reasons for something like this to happen, not the least of which being calling a pure virtual method from the base class’ constructor . In this post we’re going to see something slightly less traditional...
Almost two years ago, I wrote about the TR1, a set of additions to the C++ standard that was implemented in a Feature Pack for Visual Studio 2008. Back then, I gave the post a rather provocative title: C++ Developers Just Got Lambdas? Well, now we’ve got them. The new C++ standard , dubbed C++0x (where the x is going to be a hexadecimal digit, hopefully A) has lambda functions as one of its features. Visual Studio 2010 implements some of the standard (draft), including lambda functions. Yesterday...
Dana Groff, Senior Program Manager on the ConcRT team is going to talk about the new Concurrency Runtime – an abstraction on top of the underlying operating system, supported from Windows XP through Windows Server 2008 R2. The ConcRT Resource Manager is an abstraction over the hardware that allows vendors like Microsoft and Intel (OpenMP, TBB) to program at a higher layer and compose these platforms, as well as coming up with one set of concepts for providing parallel code such as tasks, task groups...
Here’s a good interview question or riddle for seasoned C++ developers. You’re asked to design a set of template functions for automatic conversion of data from one type to another. First of all, you’re expected to have a function called scalar_convert<T> for converting values of type T to values of another type that depends on T . Part of the assignment is to come up with a mapping between T and the target type without requiring the caller to pass it along as a template parameter. Next, you...
A few weeks ago we took a detailed look at the intrinsic details of providing Windows 7 taskbar tab thumbnails and live previews in a Win32 application . As part of that post I mentioned a C++ wrapper called TabWindow which takes care of most of the nasty details and leaves only the work of creating the tab controls and rendering them to the application developer. Here’s the public API of the TabWindow class and its corresponding TabWindowEventsSink callback interface (slightly edited to fit): class...
A few months ago, we’ve taken a look at how you can extend your MDI or TDI application with an individual thumbnail and live preview for each tab (or document) that will be displayed in the Windows 7 taskbar. We’ve seen the temporary managed wrapper that makes this possible, and in the final 1.0 release of the Windows API Code Pack there is a more polished managed API that does the same thing. However, in this post I’d like to focus on the underlying details which you will have to deal with if you...
More Posts
Next page »