« Books | C++ Tips Archives | CC.Net »

C++ Tools - JetBrains ReSharper C++ - purchased...

| 0 Comments
I've been looking at Resharper C++ by JetBrains for a while now and the trial period has finally run out. I immediately bought a license which shows how my feelings have changed about the product during the trial.…

C++ Tools - CppDepend

| 0 Comments
I've been trying various static analysis tools on the C++ code of The Server Framework. So far I'm using Resharper C++ and the Gimpel PC-Lint Plus Beta on a regular basis and I've now added CppDepend into the loop. Full disclosure. I have been given a CppDepend license. As I've said before, whilst CppDepend is easy to get hold of, easy to install and "just works" I don't find it that useful. I can certainly remember large enterprise clients where this kind of tool would be invaluable for management level analysis of large codebases but for a small development team…
I've been looking at Resharper C++ by JetBrains for a while now and I expect I'm nearing the end of the trial period. Initially I found it got in my way but slowly I think it's training me to ignore the niggles and I'm finding the functionality quite compelling.…
Following on from my rant about C++ tooling and its follow up. I've been looking at JetBrains ReSharper for C++. This isn't a review, more just my initial thoughts. TL;DR I'd like to like it. It does some good things but it also gets in my way and slows me down. ReSharper is a Visual Studio addin. In general I don't like addins but this comes from my years working short contracts and multiple clients where it was easiest to be at home in a clean Visual Studio installation as no two clients would have the same addins installed. ReSharper's…
I've been a big fan of Gimpel Lint for years. It's a great static analysis tool for C++ and it can locate all kinds of issues or potential issues in the code. My problem with it has always been that it's a bit of a pig to configure and run, more so if you're used to working inside an IDE all the time. Several years back I had some custom Visual Studio menu items that I'd crufted up that ran Gimpel Lint on a file or a project and some more cruft that converted the output to something clickable in…

Intrusive C++ containers

| 0 Comments
Recently, whilst continuing to improve the performance of various aspects of The Server Framework, I reached a point where I found I needed to replace some STL containers with intrusive containers which didn't need to perform memory allocations during data insertion and removal. I had been toying with the idea of implementing custom containers for some time but have only recently had a pressing need for them. The STL provides some marvellously usable code which has changed the way people view container classes in C++. The result is that you hardly ever need to write your own containers as the…
Today I discovered that C++ scoped static initialisation (function level) in Visual Studio is not done in a thread safe manner. It's the kind of thing that I should have already known but I guess I assumed that since namespace level static initialisation was safe so was function level static initialisation. Unfortunately it's not. If you read the MSDN documentation in a particular way you could decide that the docs say that it's not; but it's imprecise and unclear and I doubt that I did read the MSDN documentation anyway. Looking at the generated code from Visual Studio 2013…
It seems that isprint() is broken. The following program demonstrates the problem. In VS20013 it prints "test failed" in all previous versions of visual studio it prints "test passed". From this reference: http://en.cppreference.com/w/cpp/string/byte/isprint it seems that VS2013 is broken. I've opened a Microsoft Connect issue for this. #include <ctype.h> #include <iostream> int main() { int c = 9; if (isprint(c)) { std::cout << "test failed" << std::endl; } else { std::cout << "test passed" << std::endl; } return 1; }…

C++ 11, Concurrency

| 0 Comments
I've been watching Bartosz Milewski's C++ 11 Concurrency videos and they're a pretty good way to get up to speed on the new threading support in the latest C++ standard. They start off nice and slowly, for people who haven't been doing concurrency for years, and explain the various new features provided by the language. It's good stuff. I've been reading Anthony Williams' C++ Concurrency In action which is a great way to understand the details of what you'll see in the videos. It's a good book and there's lots of useful stuff in there even if you've been…

The curious case of the missing copy constructor

| 0 Comments
I have a tendency to write unit tests that are a little more invasive than they need to be; these tests make sure that not only are the results as expected but also that as many of the side-effects and interactions with other objects are as expected as well. So, for example, in my current WebSockets development for The Server Framework I have some tests which test that the correct data is delivered to the client of the API that I'm developing and also test that the API interacts with its buffer allocator correctly and doesn't leak memory. The…

Invasive containers

| 1 Comment
Rather than immediately dive into the fun of writing my own invasive alternative for std::map I decided to take a look at what has been done before, as expected boost contains something that might work in the shape of the "intrusive containers library". Of course, being part of boost I first have to work out exactly how much more of boost it will require me to depend on and then I have to work out how I can use it to replace my current std::map usage. It seems quite clever (no surprise there) and allows for a type to be…

STL allocators, hmm...

| 3 Comments
As I mentioned a while ago, I have some code which needs to perform better than it currently does and one of the areas that could be improved upon is the amount of contention for the heap that's occurring. The fact that I'm using an STL map for my collection means that the class has a 'big C' contention value of C(n threads using the heap) rather than C(n threads using the object). Of course, the fact that allocations need to be done at all is an unfortunate feature of std::map but rather than immediately replace the container with an…

Speeding up C++ builds

| 8 Comments
I stumbled on an idea for speeding up C++ builds the other day and it's not something that I've considered before and it really does offer a considerable speed up so I think it may be worth considering in some situations. It has downsides which make it harder to use with my default style of code structuring but the increase in build speed is tempting... The idea is that of "Unity builds" which I discovered from an answer by Christoph Heindl on Stack Overflow about how to speed up Visual Studio builds. Christoph refers to this blog entry; The Magic…

The most important C++ stuff, ever...

| 0 Comments
I'm still skiing in Argentina, the training is going well and within 3 weeks I'll know if I make the grade and qualify as a BASI Ski Instructor... Because of all the skiing and partying and work out here I haven't been keeping up with many technical issues but this morning I checked bloglines and picked a couple of random feeds to catch up on. One of them was the Artima C++ Source feed which has recently published 5 articles by Scott Meyers. These articles are five lists of five of the "Best C++ ... ever", one on books, one…
In the fight to make C++ code easier to reason about and understand, never underestimate the value of a name. Giving something a decent name is the first step in thinking about the concept at a slightly more abstract level. Abstraction is all about selective forgetfulness, by grouping together several related program elements, defining a concept and giving that concept a name you can, from then on, choose to work at the level of the name rather than the detail. This has a marvellous effect on the amount of information that you can hold in your head at the same…

C++ Tips: 3 - Strive to be const correct

| 0 Comments
Another extremely powerful tool that you can use to ensure that your C++ code communicates as clearly as possible is const. By correctly using const all the time when designing your abstractions you can divide an object's interface into two smaller, easier to understand interfaces; one which does change the object's internal state and one which doesn't. By correctly using const all the time when defining constants and variables you can clearly communicate which are which. Strive to be const correct.…
When designing code it's often easy to include undefined behaviour. The need for code that exhibits this kind of behaviour is, however, generally pretty rare and there are often ways around allowing undefined behaviour. In general it's usually best to try to avoid undefined behaviour and instead be clear about exactly what happens under all usage conditions.…

C++ Tips: 1 - Avoid unnecessary optionality

| 7 Comments
One of my main aims when writing code in C++ is to have the code clearly communicate its purpose. I find it useful to be able to look at a single line in isolation and have a pretty good idea of what its effects are on the code that it cooperates with. Unfortunately C++ code can often be written in an imprecise way that makes reasoning about what it actually does harder than it needs to be. By increasing the precision of your code writing you can limit what the code could potentially do to just what you want it…
« Books | C++ Tips Archives | CC.Net »

About this Archive

This page is an archive of all entries in the C++ Tips category.

Books is the previous category.

CC.Net is the next category.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing