DCSIMG
C++ - All Your Base Are Belong To Us

All Your Base Are Belong To Us

Mostly .NET internals and other kinds of gory details

Browse by Tags

All Tags » C++ (RSS)
Revisiting Value Types vs. Reference Types
Why do C#, the .NET Framework, and the CLR need value types and reference types? Why two categories of types? Why the added complexity in training developers to understand why and when to use each type of type? There are many answers, but very few get to the crux of the matter. You could try to justify the need for two types of types by looking at the semantic differences C# affords each. For example, you know that by default, instances of value types are copied when passed to a function, but instances...
P/Invoke with C++ bool Return Values
I encountered an interesting gotcha today, which I thought would be interesting to share with you. The symptoms were the following: I wrote a simple C++ function exported from a DLL, and tried to invoke it using a P/Invoke wrapper. The C++ function returns a bool , and was declared as follows (the code was simplified for expository purposes): extern "C" __declspec(dllexport) bool IsPrime(int n) {     if (n <= 1) return false;     if (n == 2) return true;...
Runtime Representation of Generics—Part 1
This is an excerpt from Chapter 5 (Collections and Generics) of Pro .NET Performance , scheduled to appear in less than a month. I might be publishing a few more of these before and after the book is out. Before we can concern ourselves with the runtime implementation of generics, it’s paramount to ask whether there is a runtime representation of generics—as we will see shortly, C++ templates, a similar mechanism, have no runtime representation to speak of. This question is easily answered if you...
New C++ Concurrency Static Analysis Warnings in Visual Studio 2012
Another cool feature in the Visual Studio 2012 C++ compiler is the revamped code analysis rule sets and brand new UI for configuring them. This is not just the simple /analyze switch we all know and love since Visual Studio 2005 anymore. To get a general impression of the UI changes, open a C++ project’s properties and check out the Code Analysis node. You’ll be able to review the rule set that runs on your project and optionally enable/disable specific warnings. Check out some of these rules: Specifically...
Sessions From SELA C++ Conference: “The Style of C++ 11” and “The Future of C++”
Thanks for coming to my talks today at SELA’s C++ conference! It’s been a great audience and there was lots of interest in the new standard and what’s still coming ahead. There are still two more conference days ahead of us, and it’s great C++ born again! You can view my two talks below. The Style of C++ 11 The Future of C++ View more presentations from Sasha Goldshtein . I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn
Visual Studio 2012 C++ Auto-Parallelizer
As you might have gathered from some scarce reports on the Web and the initial list of new features in Visual Studio 2012, the new C++ compiler is now capable of automatically vectorizing loop bodies—a feature I’ve already covered here, and also automatically parallelizing them using multiple threads. Here’s an example. Consider the classic prime number calculation loop, designed to count the number of primes in a given range: __declspec(noinline) bool is_prime(int n) {     for (int...
SELA C++ Conference Is Near!
I just realized that I completely forgot to tell you about the C++ conference we’ve having in the middle of June. Basically, we realized that there’s a lot of latent interest in C++ – what with the “C++ renaissance” – that we are not tapping into with our SDP conferences. Even though the last SDP had sessions on C++11 and debugging C++ applications, we felt there was room for more. At the C++ conference on June 18-20, we have two parts, as usual: a day of breakout sessions at the Crowne Plaza hotel...
Slides from the Second Jerusalem .NET/C++ User Group Meeting
Yesterday we hosted the second meeting of the Jerusalem .NET/C++ User Group . We have a temporary website now, which I encourage you to bookmark to stay up to date with the group’s meetings. (I will also post any news to my blog, of course.) The two presentations from the event are below. They were deep technical talks, and I strongly recommend that you peruse the links sprinkled throughout the slides for a deeper understanding of the topics. Portable Lock-Free Use of STL Containers Visual Studio...
Second Meeting of the Jerusalem .NET/C++ User Group
The second meeting of the Jerusalem .NET C++ User Group will take place on May 29. This time we’ll be talking about advanced C++ topics. If you’re a developer in the Jerusalem area working with C++, this is the user group for you! Slides from the previous meeting’s talks are available online if you’d like to catch up on what you might have missed last time. The agenda for this meeting is as follows: 18:00-18:15 – Networking and refreshments 18:15-19:00 – Portable lock-free use of STL containers ...
Slides from the First Jerusalem .NET/C++ Meeting
Last Tuesday we hosted the first meeting of the Jerusalem .NET/C++ User Group . I forgot to take pictures, but we were a nice group of hardcore C++ developers eager to learn about the new C++ 11 features, debugging C++ code in production, and some memory management tricks relevant for C++ real-time applications. As promised, below are the presentations from the event. My presentation on C++11 covers lambdas, auto variables, rvalue references and even touches briefly on the subject of variadic templates...
Announcing the Jerusalem .NET/C++ User Group
Event Registration Online for First Meeting of the Jerusalem .NET/C++ User Group I’m proud to announce the first meeting of the Jerusalem .NET/C++ User Group , which will take place on March 20! This user group is the product of collaboration between yours truly, SELA Group , and BrightSource Energy , and strives to be the meeting place for developers in and around Jerusalem working with .NET and C++ technologies. Here’s the agenda for our first meeting – I recommend that you register quickly because...
Stack Unwind Does Not Occur When C++ Exceptions Propagate Into Managed Code
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...
SDP December 2011: Everything New in C++
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...
SIMD-Optimized C++ Code in Visual Studio 11
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...
Debugging Optimized Code in Visual Studio 11
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...
More Posts Next page »