C++ annotated: Sep – Dec 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: September – December 2016

In this edition:

Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Introducing Phil Nash, Developer Advocate for C++, Objective-C and Swift tools

Phil NashPhil Nash has joined us recently as a Developer Advocate for C++, Objective-C and Swift tools. Here we talk to Phil about his experience and interests and introduce him to all of you.

Twitter: @phil_nash
Blog: levelofindirection
GitHub: philsquared

A: Hi Phil, and welcome to the JetBrains team! Let’s talk about you. Can you please share a bit about yourself?

P: Hi Anastasia. Thanks for having me here. A bit about me? Well, I’ve been programming since I was 9. Like most who came of programming age in the early 80s, I started with various versions of BASIC on 8-bit home computers (ZX-81, ZX-Spectrum, Commodore-64, BBC Micro and others), but within a few years progressed on to assembler (mostly 6502 – but later 68000 on the Amiga, then 8086 on PC). In the early 90s I went for my first programming job, writing C & C++, which I prepared for by reading a book on C the night before. Somehow I managed to bluff my way in – but I hadn’t been there long before I realized I knew more C++ than anyone still there. That was the start of my C++ journey. It started on MS-DOS, but as the 90s progressed I naturally fell into Windows – which I did exclusively for the rest of the 90s.

A: What’s your background as a developer? I know you did C++ on Windows for a very long time. How did you end up doing iOS development in Objective-C and now Swift?

P: In the 2000s I changed things up a bit. The signs were there that C++’s heyday was coming to an end and I thought I should either learn other languages, or see which industries C++ would remain strong in. I started with the latter and moved into embedded programming – specifically mobile comms – where I stayed for about five years. It was a good experience and I’m glad I did it, but I also learned that embedded-programming was not for me. So I branched into banking, where I’ve mostly stayed until now. During that time, though, I also moved on the “other languages” front. First C#, then Python, then D and F#. At home I’d switched over exclusively to Macs, so I was interested in learning Objective-C, but it wasn’t until the iPhone AppStore launched that I gathered sufficient motivation to get past the initially steep learning curve!
Continue reading

Posted in Uncategorized | Tagged | Leave a comment

What’s New in ReSharper C++ 2016.2

As a part of ReSharper Ultimate 2016.2, our C++ team is happy to present the ReSharper C++ 2016.2 update. All in all, the new release comes with 200+ fixes and resolves several important performance- and stability-affecting issues. Let’s take a tour of the new features in this release.

Inline Variable

The mainline ReSharper’s refactorings continue to make their way into ReSharper C++. With the latest update, Inline Variable is now available for C++. This refactoring allows you to replace all occurrences of a variable in the code with its initializer. (The reverse functionality is already provided by the Introduce Variable refactoring.)
Inline Variable refactoring for cpp

Doxygen support

Doxygen is arguably the most popular format and tool for code documentation in the C++ world. ReSharper C++ now understands Doxygen syntax, and provides several key features to facilitate editing of documentation blocks:

  • Typing assist helps with creating new comment blocks and maintaining the structure of existing ones.
  • Code completion suggests Doxygen commands with accompanying short descriptions.
    Doxygen completion
  • Function parameter references introduced with \param commands will be reported by Find Usages and will get updated when Rename is used to change a function parameter’s name.
    Rename \param
  • Warnings are issued when function parameter references do not resolve to an existing function parameter.
    Unresolved \param

Documentation generation

You can now generate documentation for C++ declarators, classes and macro definitions. Since parsing a C++ file can require a significant amount of time, to avoid UI freezes this feature is implemented via a context action available when using Alt+Enter on the entity’s name.
Document context action
When the action is applied, ReSharper C++ uses the builtin doc live template to generate the resulting comment. The default documentation template is configured to be compatible with Doxygen syntax, but it can be customized (as usual) using the Templates Explorer tool window. An assortment of specialized documentation macros can be used inside the template, which evaluate to:

  • Short or qualified name of the entity that is being documented.
  • Function/macro/template parameter name or type (the containing template line is duplicated for each corresponding parameter).
  • Function return value, if there is one.

Quick Documentation

Thanks to Doxygen support, Quick Documentation now works in C++. The documentation pop-up (bound to Ctrl+Shift+F1 in the Visual Studio scheme or Ctrl+Q in the IntelliJ IDEA scheme) will display documentation from Doxygen comment blocks, or the symbol’s signature if no documentation is found.
Quick documentation pop-up

Code analysis

ReSharper C++ now understands several of the standard C++11 attributes and their Visual C++ counterparts:

  • Usages of functions and classes marked with [[deprecated]]/__declspec(deprecated) are reported together with the specified reason.
    Highlighting of a deprecated function
  • Not all control paths return a value and other control-flow based analyses correctly handle functions marked with [[noreturn]]/__declspec(noreturn).

Most header files should start with some form of include guard to avoid multiple inclusion. Similar to the Missing precompiled header include for .cpp files, ReSharper C++ will now warn you if a header file lacks an include guard and will provide a fix to automatically add a #pragma once directive.

Omitting noexcept specifications from user-defined move constructors and assignment operators can have serious performance implications (for an in-depth discussion refer to this blog-post or Item 14 of Scott Meyers’ excellent “Effective Modern C++”). To make sure this is intentional, ReSharper C++ will warn you about move constructors, move assignment operators and swap functions without an explicit noexcept specification, with corresponding fixes to add one.
Move constructor without noexcept

Starting with Visual Studio 2013, the Visual C++ compiler has supported explicit user defined conversions. To complement the existing Non-explicit converting constructor inspection, Non-explicit conversion operator was added. Severity for both analyses is set to Hint by default (so they are not shown as suggestions), but can be increased if you prefer to avoid implicit user-defined type conversions.
Non-explicit converting constructor

In addition to suggesting to replace zero constants with nullptr in pointer contexts, ReSharper C++ will also offer replacing integral constants with true/false in boolean contexts.
Replace expression with true

Last but not least, another new inspection detects missing default cases in switch statements and provides a fix to insert it. The same fix is also available for the Uncovered enumerators inspection.
Default case

Go to Text

A new member of the Go to family, Go to Text navigation (Ctrl+T,T,T in the Visual Studio keyboard scheme or Ctrl+N,N,N in the IntelliJ IDEA scheme), lets you quickly find and navigate to any text in source and textual files in the entire solution.
Go to text
This new feature uses trigram indexing to make text search blazing-fast. Similar to other navigation commands, if there are too many matching items you can press + on the numeric keypad to explore results in the Find Results window.

New code style options

New formatter options provide support for some commonly used styles in C++ code:

  • The Braces Layout | Keep simple compound statements in one line setting was added to allow single-line definitions of trivial functions. It can be set to force ReSharper C++ to make such functions single- or multi-line, or to simply not change their formatting.
    Keep simple compound statements in one line
  • A related setting, Blank Lines | Around single line function definitions, controls the number of blank lines that a single-line function should be surrounded with.
  • The Wrapping and Aligning | Break line before member initializer list option controls whether to start member initializer lists on a new line.
    Break line before member initializer lists

Different projects use different conventions for the syntax of #include directives – as a result, we received several requests to make auto-generated #include directives more customizable. ReSharper C++ now provides preferences about whether to insert paths relative to the current file and when angle brackets should be used instead of quotes.
Include directives settings

A couple of settings were added specifically for compatibility with pre-C++11 codebases:

  • Formatter gets an option to require a space between closing angle brackets in template arguments, to avoid a notorious parsing issue in C++98.
    Space between closing angle brackets in template arguments
  • Instead of nullptr, ReSharper C++ can be configured to use NULL or 0 for default pointer initializers.
    Default pointer initializer

Generate improvements

In addition to Google Mock, the mock function generator now supports Trompeloeil. Trompeloeil is a modern header-only C++14 mocking framework, and is a great alternative to Google Mock when your project needs a mocking library but does not use Google Test. As with Google Mock, the generator becomes available when ReSharper C++ detects that the library is included into the current source file.
Trompeloeil mocks

Several existing code generators received new options:

  • To complement the related code analysis, copy/move operations and swap function generators allow making generated functions noexcept.
  • Similar to relational operators, the equality operator generator now has an option to use std::tie.
  • The constructor generator now lets you specify the accessibility of generated constructor(s) (starting with ReSharper C++ 2016.2.1).

Auto-import completion

Code completion in C++ became integrated with auto-import and can suggest symbols that are not included into the current file. The necessary #include directives are added automatically when an auto-import item gets used.
Import suggestions in C++ auto-completion
Please note that auto-import items get added into the completion list asynchronously, so they will be available after a short delay.

Code template enhancements

If you need to surround a piece of code with a template, just select the code and type in the name of the template you need: no extra shortcuts required. Furthermore, a single template can now be used for creating code (as a live template) and for surrounding existing code (as a surround template).
Surround templates

The default C++ class and struct file templates now contain a macro that expands into an #include directive for the precompiled header file, if the project uses one.

Odds and ends

Keeping up with the language evolution, ReSharper C++ extends its support of the C++14 standard. In particular, variable templates and decltype(auto) are now supported.

When your caret is on one of the exit points of a function/loop/switch (return, throw etc.), ReSharper C++ will automatically highlight all other exit points.

Similar to Visual Studio’s __INTELLISENSE__ define, ReSharper C++ now defines its own __RESHARPER__ macro in the internal preprocessor implementation. If necessary, this definition can be used to guard code that ReSharper C++ does not understand for some reason, or to hide parts of a file from code analysis.
__RESHARPER__ define

CppCon 2016

If you are attending CppCon 2016, be sure to stop by the JetBrains booth September 20-21! Members from both the CLion and ReSharper C++ teams will be present, and we will be happy to tell you all about our products, share future plans and answer your questions. Don’t miss your chance to participate in our license raffle and win a free 1-year subscription for any JetBrains C++ product of your choice!

CppCon 2016

As always, we would like to hear your feedback – and if you have any problems or feature suggestions, do not hesitate to contact us or create a request in our issue tracker!

Posted in ReSharper C++ Tips & Tricks | Tagged , , | 2 Comments

C++ Annotated: Jun – Aug 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: June – August 2016

In this edition:

  • Interviews
  • Conferences
  • News & Stories
  • Releases


Jon Kalb speaks about CppCon, C++17 standard and C++ community


These months were quiet in terms of conferences, but September is just around the corner with the most well-known and significant event in the C++ world – CppCon. CLion’s PMM, Anastasia Kazakova, talked to Jon Kalb, CppCon Chair and C++ instructor. The first topic discussed was the C++ community and how modern language features are adopted by it. They went on talking about Jon’s feeling towards C++17 and his strong faith that the committee did everything just right. Jon also shared a secret recipe and a magic ingredient of CppCon success and a story of CppCat, and spoke about the era of tools for C++.

An interview with Sean Parent


Jens Wellers from Meeting C++ did an interview with Sean Parent. Learn why Sean would select Argument-Dependant Lookup if he could remove one feature from C++ language; why he thinks garbage collection has no place as a part of the general allocation scheme; discover his views on functional programming, smart pointers, coding guidelines and a bunch of other topics.

Stephen Kelly at CppCast


During these months many interesting episodes of CppCast were published. One of them is an interview with Stephen Kelly, Qt and CMake expert and maintainer. He talks about Qt build system and CMake similarities and how they can co-exist. While the most interesting part of the interview is dedicated to CMake API and how tools like IDEs can use it to integrate deeper with CMake, Stephen also answers questions about its design and why they dropped the idea of simply generating more content on a CMake call and decided to use the idea of the CMake server instead. In the end, Stephen shares some tips on CMake productive usage, like creating and using CMake config files.

Another great episode of CppCast worthy of a mention is an episode with Herb Sutter reviewing the results of the Oulu C++ committee meeting.
Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

C++ Annotated: March – May 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: March – May

In this edition:

  • Conferences
  • News & Stories
  • Webinars
  • Releases


ACCU 2016

accu In April, ACCU came back to Bristol, UK, as usual. The premier UK developer conference this time brought together more than 400 attendees and over 60 speakers. Four playlists with video recordings, one for each day, are already available on YouTube. Lots of interesting topics were covered this year, for example Greg Law’s talk about profound and thus less known GDB features, Diego Rodriguez-Losada’s talk about C/C++ and Python working together, a talk from our developer advocate Dmitri Nesteruk about Design Patterns in Modern C++, and many more.

Besides, ACCU 2016 Chair, Russel Winder, gave JetBrains an interview where he talked about things that make ACCU unique, as well as his experience with Rust, D and Go languages and their future in comparison to C++.

C++Now 2016

cppnow Across the pond, C++Now 2016 was held in Aspen, Colorado, in early May. Attendees could find a lot of well-known names from the C++ community joining the event, like Sean Parent from Adobe with a keynote talk about Better code, Jon Kalb with his famous O’Reilly report about C++ landscape overview, Timur Doumler, a JUCE developer from ROLI, Marshall Clow, Barbara Geller, David Sankel, and many others.

Check out the best session winners and learn about C++Now 2017 dates in the blog post.

Italian C++ Conference 2016

Another C++ event was held in Italy in May. More than 100 people attended the very first Italian C++ conference in Milan. You can find the report about the event here. In particular, we want to draw your attention to two of James McNellis’ talks, Adventures in a Legacy Codebase and An Introduction to C++ Coroutines.

News & Stories

C++17 standard news

cpp March brought several reports about the C++ meeting in Jacksonville, Florida. Herb Sutter posted a long and detailed one in his blog. Despite many expectations and hopes in the C++ community, modules and concepts won’t come to C++17. However, for now they will both stay in their own technical specification. Coroutines are targeted for another TS as well. On the good side, Herb lists the features that are making their way to the upcoming C++ standard, like Parallel STL and several more TS that were merged into the final C++17 edition, and several features coming directly to the new standard like fallthrough, nodiscard and maybe_unused attributes and more. The future of C++ is presented in Herb’s blog post in a simple timeline, followed by an interesting open-ended question: Will C++ stay on the 3-year cycle or move to a 2-year cycle?

C++11 smart pointers

C++ developers (both students and professionals) can find this blog post useful, as it uncovers 10 dangerous pitfalls when working with C++11 smart pointers. It tells you where it’s better to use shared_ptr, unique_ptr and auto_ptr; how to avoid double memory allocation by using make_shared; and lays out the rules for working with the raw pointers.

lambdas and std::function

lambda C++11 lambdas are already widely used. The idea is pretty simple. The easiest (though probably useless) example is “[](){}();”. But do we know them well enough to answer even basic questions? What is the lambda’s type and why is it not std::function? How long do the variables captured by lambda stay alive? What is the size of a lambda? If you feel like testing your knowledge of lambdas, head straight to this blog post.


conan In the previous edition we already mentioned Conan, a C/C++ package manager. This time we’d like to share more information about it. First up is a CppCast episode with Diego Rodriguez-Losada, known as a biicode startup co-founder and currently Conan committer. Watch the episode to learn the Conan story first-hand.

There is also a great post in Conan’s blog for those interested in setting up a full environment for C/C++ development based on Clang as the compiler, CMake as the build system, CLion as the IDE, and Conan as the package manager. Check the steps and follow advices for an easy set-up.

Compiler Bugs Found When Porting Chromium to VC++ 2015

64_read Bruce Dawson from Google posted some great material on the bugs found while porting a big Chromium project from VC++2013 to VC++ 2015. The incredible work includes attempts to build some smaller samples to reproduce the problems, as well as some deeper analysis of the situations. Read the post to know about a problem with zeroing a five-byte array, a crash that would happen only under Profile Guided Optimization, an incorrect 64-bit structure read, and more.

Telemetry function calls in VS 2015

telemetry Recently the C++ community has been discussing the telemetry call in every binary compiled in VS2015. The discussion was huge as conspiracy theories are always popular, even though the logs written in that case were quite limited and have to be switched on manually (so not working by default).

However, the discussion on reddit got an official comment. Steve Carroll from the Visual C++ team has promised that the corresponding calls will be removed in Update 3. He explained that the main intent was to build a framework that would help investigate performance problems and improve the quality of the optimizer.

C++ I/O Benchmark

compilers Cristian Adam posted in his blog nice and solid benchmark for C++ cross-platform calls for Input/Output on Windows 10, Kubuntu 15.10 and Raspberry PI2, testing on a huge set of compilers: GCC, Clang, Visual C++ (2013/15), MinGW GCC, Cygwin GCC and Cygwin Clang. During the test he was reading one file in chunks of 1 MB and writing it to another file. The tested API calls were: C file API (fopen, fread, fwrite), C++ API (std::ifstream, std::ofstream) and POSIX API (open, read, write). And the winner’s crown went to… POSIX. See the full blog post for some interesting numbers.


CppCast continues gathering famous C++ community members. Jens Weller talked about the Meeting C++ platform that brings the conference, site and recruiting platform to the C++ world. Get the whole story first-hand. An interview with the author of the renowned blog Simplify C++, Arne Mertz, was recorded for CppCast in March. Find the discussion of the latest standard and more topics in there. April brought an interesting discussion with Ankit Asthana about cross-platform development, Visual Studio Code and Visual Studio for Linux. Elena Sagalaeva (known by the Russian-speaking community for her famous blog on C++ in Russian) attended the podcast in April as well, talking about distributed computing and how the latest C++ standards are useful there.


Design Patterns and Modern C++

The recording of our May 24th webinar, Design Patterns and Modern C++, is now available on JetBrainsTV YouTube channel. In this webinar Dmitri Nesteruk shows how the classical design patterns that arose in 1994 from the infamous Gang of Four book continue to be as useful to this day. We are discussing the adapter pattern, the builder pattern and the maybe monad. Several questions from the webinar answered by Dmitri can be found in the corresponding blog post.


GCC 6.1

gcc-logo The new major release of GCC compiler was announced and brought lots of goodies. First of all, C++14 is set as a default. Besides, many features from the upcoming C++17 were added to the compiler (for both language and standard library), and even Concepts, that were postponed by the committee to another TS, are available in GCC 6.1 via -fconcepts.

Checking the list of the General Optimizer Improvements in the release notes, you may notice an interesting point that C++ developers definitely should heed: “Value range propagation now assumes that the this pointer of C++ member functions is non-null”. You may want to check whether your code base is affected by the change, just as it happened to Qt5, Chromium and KDevelop. Anyway, GCC authors suggest a temporary workaround: -fno-delete-null-pointer-checks.

Clang 3.8

libclang A lot of goodies were delivered with the Clang 3.8 release, including OpenMP 3.1 (and several elements of the OpenMP 4.0/4.5), experimental support for end-to-end CUDA compilation, static analyzer improvements, and more. You can also track the progress of the new features through the Clang 3.9 (in progress) release notes.

ReSharper C++ 2016.1

R++_400x400_Twitter_logo_white April brought the release of ReSharper C++, a Visual Studio extension for C++ developers. In addition to Google Test support, Boost.Test is now added, including a built-in test runner. This version allows you to mark your code with TODO, BUG, FIXME or any other pattern you may prefer (configurable in settings), and navigate through the marks easily using a special Todo Explorer.

The release also brought a long list of new quick-fixes and context actions that help improve the code, by suggesting various fixes. One example is when ReSharper C++ detects an uninitialized constructor parameter, it offers a context action to create and initialize the corresponding field. Find more details about the new version in this blog post.

CLion 2016.1

CLion_400x400_Twitter_logo_white CLion, a cross-platform IDE for C and C++ developers, got an important update. Release 2016.1 finally brought variadic templates support and auto-import for STL symbols. Quick Documentation pop-up was enhanced with the hyperlinks to the related symbols. During debugging users are now allowed to attach to the process running on a local machine but not started from the IDE – all the benefits of the built-in debugger UI are still there.

To speed up the indexing time, CLion 2016.1 lets you mark directories as excluded (several more option like libraries or sources are also available).
Overgrowing just C and C++ development, CLion turns to the multi-languages projects bringing Python and Swift support on board. Feel free to check the details in the CLion’s blog.

Finally, CLion started a new Early Access Program for version 2016.2. This build addresses Doxygen support, Complete Statement and VCS changes, CMake rename refactoring for users symbols and more.

Qt Creator 4

qt Qt came out with big news in May and released Qt Creator 4.0.0. It includes CMake workflow changes (like automatic triggering when necessary, UI to change the CMake configuration for a build directory and more), automatic use for the Clang code model, Clang static analyzer integration available under open source, fixes for the latest LLDB version and several more improvements.

Visual Studio 2015 Update 2

vs_cpp Microsoft has given us a lot of exciting news in these months. Update 2 comes with many interesting changes for C++ developers. C++ compiler got many bug fixes, with the most notable changes including support for Variable Templates and constexpr improvements. At the same time, many C++17 features have made their way to C++ standard library as well.

However, the biggest improvement is probably for those who develop for Linux, as the new extension makes possible C++ development in Visual Studio for Linux. You can now create projects and manage connections to the Linux machine right from the VS. Upon connecting, VS will copy your sources to the remote Linux machine and will invoke GCC to build the sources with the options from the project properties. Then you can debug your code remotely.

Looking into the future of Visual C++ compiler, read this blog post about upcoming changes in Visual C++ code optimizer. Find out the reasons behind the new optimizer, and see several samples of implemented optimizations.

That’s it! Let us know in the comments if you like current edition.

The C++ Team

Posted in Uncategorized | Tagged , | 1 Comment

What’s New in ReSharper C++ 2016.1

Apart from the change in version numbers, ReSharper C++ comes with plenty of new features as well as improvements to existing functionality. Here’s what we’ve got in store for you with this release.

Boost.Test Support

The previous release of ReSharper C++ provided a unit test runner for Google Test — well, this one augments this with Boost.Test support. This includes all the usual refinements users of our unit test infrastructure are used to. ReSharper will detect individual Boost tests as well as test suites:

ReSharper C++ Boost.Test Detection

There is also support for test labels:

ReSharper C++ Boost.Test Label Support

And of course it will use its unit test runner to actually run those tests and show a listing of the results.

ReSharper C++ Boost Unit Test Runner

Please note that Boost.Test support requires Boost 1.59 or later.

Todo Explorer

The Todo Explorer is a separate tool window that has long existed in the original ReSharper but is now coming to ReSharper C++. Its goal is to find text that matches a specific pattern in comments, strings or identifiers and show all the located elements in a single, easy-to-browse list:

ReSharper C++ Todo Explorer

There are plenty of filtering and grouping options in this window, and double-clicking each element takes you right to the line of code where the relevant piece of information was found. ReSharper comes with support for TODO and BUG in comments, but you can easily add other markers or create new ones:

ReSharper C++ Todo Explorer Edit Pattern

As the above screenshot demonstrates, you can define the regular expression to search for, the type of code element (comments, strings, identifiers) to search in, and you can also control the color that’s used for this type of item in the Todo Explorer.

Context Actions and Quick-Fixes

As with all releases, we keep expanding the set of context actions and quick-fixes that ReSharper C++ provides. Here are a few examples.

If an out-of-class member function signature fails to match the prototype in the class body, ReSharper C++ now offers two quick-fixes to change that:

ReSharper C++ Change Signature

Choosing Use signature…, the signature of the function definition will be changed to the one of its declaration. Choosing Change signature… does the reverse, changing the declaration so that it matches the definition.

ReSharper C++ Change Signature Refactoring

When ReSharper C++ detects an uninitialized constructor parameter, we now offer a context action to create and initialize the corresponding field

ReSharper C++ Create and Initialize Field

When ReSharper C++ detects possible unintended object slicing, it offers the option to perform a static_cast:

ReSharper C++ Possible Unintended object slicing

If the type of variable being returned from a function does not match the type in the function signature, ReSharper C++ offers the options to adjust either the return type or the type of variable being returned:

ReSharper C++ Incorrect Return Type Quick-Fix

In fact, we have a more general mechanism for detecting type mismatches: for example, assigning an int variable a string literal will present you with the following:

ReSharper C++ Change Type

If you try to assign a read-only member in a const function, ReSharper C++ now offers you quick-fixes to either to make the member mutable or make the function non-const:

ReSharper C++ Make Member Mutable

If a base class or its function has a final modifier, ReSharper C++ will highlight the error over both the final keyword as well as any overriding classes and offer you a quick-fix to make the base class non-final:

ReSharper C++ Remove Final Keyword

New context actions are also provided to flip operator arguments and negate boolean expressions:

We’ve added fixes and context actions for working with includes: analyses related to precompiled header usage, context actions to normalize slashes in include paths, support for replacement of quotes with angle brackets (and vise versa).

ReSharper C++ Quote Replacement

In addition to the bulk generate definitions action, we now have bulk Move Function Implementations context action. Simply select several function bodies and press Alt+Enter:

ReSharper C++ Move Function Implementations

Rename Refactoring Improvements

And there are additional fixes, too. For example, the Rename refactoring now works on files, and will rename both the file as well as any usage (e.g., in #include directives) of the file:

ReSharper C++ Rename Refactoring on Files

It’s also worth noting that the Rename behavior on an ordinary class will now affect the header/cpp filenames, too.

Code Generation

We’ve made improvements in the code generation functionality. For example, when generating relational operators, ReSharper C++ now offers the option of using std::tie:

ReSharper C++ Code Generation Relational Operators std::tie

Another feature we’ve added to the Generate stream operations feature is the support for the use of Boost for purposes of serialization:

ReSharper C++ Stream Output Private Boost.Serialize Operations

And a Few More Things

Starting with version 2016.1, the Find Code Issues functionality works in the background in both ReSharper and ReSharper C++. This lets you keep editing or navigating your code while ReSharper runs its analysis.

The list of C++ language features supported by ReSharper C++ has also been extended with support for generalized lambda captures, exception specifications and inheriting constructors. We also have formatting options now being taken into account when generating code.

The formatting settings have a new page for controlling blank lines.

Finally, all ReSharper C++ actions are now actively banned from changing the code of any of the C++ libraries that you might be using.

So that’s it! Enjoy the new release of ReSharper C++, and be sure to let us know what you think!

Posted in News & Events, ReSharper C++ Tips & Tricks | Tagged , , | 5 Comments

C++ Annotated: Dec – Feb edition

Today we are happy to share our next compilation of C++ news with you.

To subscribe to regular C++ annotated use this simple form and be the first to get the next edition!

C++ Annotated: Dec – Feb

In this edition:

  • Conferences
  • News & Stories
  • Releases


Meeting C++

Meeting C++ 2015, the final C++ event in the year, was held in Berlin, December 4 & 5. Focused on Embedded Development this year, it was a great meetup for C++ developers from Europe and all over the world. Lots of interesting topics were covered, from the fantastic opening keynotes by Chandler Carruth about “Understanding Compiler Optimization” and James McNellis talking about “C++ Coroutines” to interesting lightning talks like Daniel Jasper’s about clang-tidy. There is a playlist available on YouTube with all the videos from the conference. Go on and check the topics you are mostly interested in!

meeting_cppBy the way, it was great to meet so many C++ developers at our booth at the conference. Thank you for coming up with lots of interesting questions. See you next year!

JetBrains C++ team in San Francisco in March

Our C++ team is up for a couple of big events in San Francisco area this March. We are happy to be the part of the world’s largest and longest-running professionals-only game industry event – GDC 2016 (join us at booth 1743). And in case you prefer local meetups – come and see us at San Francisco Bay Area C++ user group meetup (March 15) and Association of C/C++ Users’ Silicon Valley user group meetup (March 16).
Continue reading

Posted in News & Events | Tagged , | Leave a comment

C++ Annotated: Fall 2015

Fall is nearing its end, winter is coming, and we are ready to bring our next compilation of C++ news.

To subscribe to regular C++ annotated use this simple form and be the first to get the next winter edition!

C++ Annotated: Fall 2015

In this edition:


CppCon 2015

CppCon 2015 was the most remarkable event this Fall in the C++ world. It was a great week in Bellevue, full of fantastic talks, meetings, and even a first ever CppCon exhibition running during the conference days. This year, CppCon was held under the banner of code quality and code analysis. It was all started by Bjarne Stroustrup presenting C++ Core Guidelines, a collaborative effort intended to formalize some rules for writing good C++ code and encourage effective use of Modern C++. Moreover, Bjarne was talking about the “need for tools”, because the initial idea is also to make these rules machine-checkable.

The topic was later fleshed out by many other speakers, including some great examples of static analysis checks from Neil MacIntosh in his two talks (“Static Analysis and C++: More Than Lint” and “Evolving array_view and string_view for safe C++ code”). Microsoft presented their Guidelines Support Library, which contains types and functions to comply with C++ Core Guidelines presented.

The playlist of all recorded talks is available on the official CppCon YouTube channel, in addition to all the lightning talks playlist, which by the way includes two C++ IDE presentations: Emacs as a C++ IDE by Atila Neves, and CLion Tips & Tricks by Dmitri Nesteruk.

And, incidentally, the dates for CppCon 2016 have already been announced: September 18th through 23rd, 2016.

Meeting C++

While CppCon 2015 has already passed, another great C++ event is coming: Meeting C++ 2015, in Berlin, 4-5th December. The conference will be opened by Chandler Carruth from Google talking about Understanding Compiler Optimization. The schedule is also full of great names like James McNellis, Michael Wong, Lars Knoll and many others. Dmitri Nesteruk, our developer advocate, is going to give a talk on Rapid Prototyping in C++, demonstrating how one can beat the (relatively slow) C++ compiler in order to write and test code more efficiently. And in case you are a happy owner of a Meeting C++ 2015 ticket, we’ll be delighted to meet you at the JetBrains booth for a chat, QA and demos!

JUCE Summit

If you are involved in any kind of software development in the audio tech industry (or just doing audio software as a hobby), you may have heard about JUCE, a C++ cross-platform framework that has plenty of options for audio management while working with audio files, and at the same time provides instruments for building UI (similar to Qt; iOS developers can find some parallels with Reveal app). CppCon 2015 participants had a chance to learn about JUCE during the lightning talk by Julian Storer, and CppCast listeners may remember a recent episode with him.

In November, the JUCE Summit was held in London, covering some interesting topics around audio software development. These included workshops and training around Producer, the tool behind JUCE; questions about mixing JUCE and native APIs for developing for both iOS and Android; pure C++ language related topics; and some general software development topics during the guest talks. We look forward to a recording of the talks appearing soon!

News & Stories

First off, congratulations are in order on two important birthdays:

CMake Celebrates 15 Years

cmakeCMake turned 15 in the last days of summer. Congratulations to a great cross-platform solution that lets people manage builds in effective and flexible ways on many platforms!

To prove that the growth is not slowing down, CMake 3.4 was released on November 12, including several great features like the ability to honor *.manifest source files with MSVC tools, some initial and basic support for Apple .swift source files, many new commands, and other changes.

30th Anniversary of Cfront

cpp_firstYes, 30 years have passed since CFront 1.0 was announced at the ACM conference by Bjarne Stroustrup! Do any of our readers remember that year? In the interview Bjarne said, “It was a big day for me, but the only thing I remember is getting the first copy of my 1st edition” (meaning the first edition of The C++ Programming Language).

That was 30 years ago. Now C++ is used by millions of developers across the world, an impressive family of C++ compilers and the C++17 standard is under discussion by the committee—a great story for the language, and we hope it continues for many more years!

News from the Visual C++ Team

vs_cppIn September, the Visual C++ team posted a survey in order to understand how many people use GCC- and LLVM-based compilers targeting either Windows or Linux. It offered eleven different questions about language, compiler, debugger, IDE and platform used for development, cross-platform options, and debugging procedures. Have you participated?

In the beginning of November, the team also introduced a couple of experimental editor tools through the new “Experimental” mechanism. It allows you to play with the new features and participate in its evolution, and lets you disable any of the features should you find them not to your liking. The list of new experimental features includes automatic replacement of ‘.’ with ‘->’ when applicable, Extract Function and Change Signature refactorings, and more.

The Visual C++ Team also announced a separate package with standalone C++ tools, not including Visual Studio IDE, but with compiler, header files, libraries and more.

Clang 3.7 Released

llvmClang, the LLVM front-end, saw another release too. New things included initial support of __try/__catch__finally SEH language constructs, improved support for OpenMP (including OpenMP 4.0 omp simd directive), and an implementation of control flow integrity, a security related mechanism. Clang also saw some improved diagnostics, including range loop analysis, inspections related to move operations, and detection of infinite recursion.

And, speaking of Clang/LLVM, check out the videos from the 2015 LLVM Developers’ Meeting which took place in late October in San Jose, California. The playlist has many interesting talks covering LLVM, OpenMP, GPU support and many other topics.

CppCast Episodes with Scott Meyers, Andrei Alexandrescu and Other Great Guests

CppCast, a podcast by C++ developers for C++ developers, hosted by Rob Irving and Jason Turner, has presented several fantastic speakers this fall. It started with an appearance by Scott Meyers in September, who spoke about the “Effective C++” series of books and gave advice to those who have valuable C++ knowledge to share: pay attention to modern video formats, not only books.

Another episode has Andrei Alexandrescu talking about C++ and D, and reasons why programming languages succeed or fail. Kate Gregory, this year’s Open Content Chair for CppCon, talks about the proper way of teaching C++. Dmitri Nesteruk, a JetBrains developer advocate, speaks on his favorite High Performance Computing topics.

Arduino Support in CLion

arduino2There is a very popular request in our tracker about built-in Arduino support in CLion. However, since the team is currently quite busy with other things, our users try to find workaround and other possible solutions. First, there is a project on github joining Arduino and CMake, which makes it possible to open Arduino projects in CLion. This project became a foundation for the CLion plugin, which you can find in the repository.

Another tool worth mentioning here is PlatformIO. In a nutshell, it is a cross-platform open source code builder that recently became quite popular for embedded development. It currently provides support for a range of platforms, including Arduino. The IDE integrations list looks quite impressive, and includes many famous names like Atom, Qt Creator, Visual Studio and CLion. Speaking of latest, we can’t miss a short but very useful post about using PlatformIO to get started with Arduino in CLion IDE.

Living with Microsoft C++ Compiler Bugs and Ambiguities

compilerThe ReSharper C++ team came out with a blog post covering some examples of nonstandard behavior of the Microsoft C++ compiler that they faced while working on the ReSharper C++ extension to Visual Studio.

There are plenty of interesting cases, from generating comments with macros to the binding of rvalues to lvalue references via an extension, problems with 2-phase look-up for templates and more. Digging into the C++ standard, Dmitri Nesteruk describes cases that are compiled successfully with MSVC, but not with GCC or Clang. The post was warmly welcomed in the community and Herb Sutter responded in the comments, explaining when and what is planned to be fixed.

Applying Genetic Algorithms to Automatic Code Formatting

formatAnother story came from the CLion team and is dedicated to the topic of extracting a set of code formatting options from actual formatted code.

This originated as a project in our traditional JetBrains Hackathon this summer, but quickly made it into the product as it brings real value. This technique helped us extract several famous code styles and build them into CLion, including code styles by Google, GNU, Qt and Stroustrup, and braces rules by Allman, Whitesmiths, and K&R. If you’re wondering why or how exactly genetic algorithms helped accomplish this, check out the blog post and learn about genotypes, fitness functions and the way these optimizations function in real life.

New Versions of CLion and ReSharper C++ Released in November

This fall brought a day of big release to JetBrains and its customers. November 2nd was a day when we updated the entire JetBrains Toolbox that includes all of our desktop tools, and also launched our new subscription-based licensing model for these products. This also included an update for our C++ tools.

clion_cppOn the CLion side, the biggest feature was Google Test support integration. That means CLion’s users can now benefit from the built-in test runner with a lot of capabilities for browsing results and restarting tests, together with the smart code generation feature. And that’s not all!

rscppAs for ReSharper C++, it has extended its support for the C language, and now provides better support for C99, including designated initializers. It also works with all C11 features that are supported in Visual Studio. C++11 and C++14 support was also improved, together with many other changes.

In other news:

  • Agustín “K-ballo” Bergé highlights the efficient way of using parameter pack and variadic templates.
  • Meeting C++ shares great tips on starting and running a User Group.
  • Bjarne Stroustrup and Herb Sutter published detailed reports about Fall 2015 ISO C++ standards meeting.


In case you missed recent JetBrains webinars, you’ll be glad to know all the recordings are available.

First was Generative Art in C++, which discussed an algorithm using nested smooth functions to create artwork of arbitrary complexity and size. Not only that, it is also a good overview of the hottest parallelization topics from C++: OpenMP and Threading Building Blocks, Intel’s Math Kernel Library, Message Passing Interface and some more.

The second webinar was for Visual Studio users, covering many of the available extensions to this great platform like NuGet, GhostDoc, C++ Debugger Visualizers, IncrediBuild, ReSharper, and many more. Watch the recording to learn ‘who is who’ here in that list and how you can benefit from each of the tools.

That’s all, folks.
We hope you enjoyed this edition of JetBrains C++ Annotated. Do let us know what you think!

Posted in News & Events | Tagged , | Leave a comment

Webinar Recording: Customizing the Visual Studio Environment

The recording of our recent webinar with Dmitri Nesteruk, Customizing the Visual Studio Environment, is now available on JetBrains YouTube Channel.

Visual Studio is a great platform and supports plenty of customization – anything from small plugins that offer cosmetic changes to large-scale infrastructural extensions that drastically alter the entire development experience. In this webinar, Dmitri Nesteruk talks about some of the available extensions to Visual Studio, discussing what they do, showing how to operate them and what benefits they bring.

00:15 – Disable Social Features
07:00 – NuGet
08:35 – ReSharper NuGet Explorer
12:40 – GhostDoc
15:10 – ArrayPlotter
17:00 – C++ Debugger Visualizers
18:30 – Tabs Studio
20:30 – IncrediBuild
24:25 – FastBuild
29:30 – Intel Parallel Studio
46:20 – Microsoft DSL Tools
50:40 – ReSharper Extensions
52:00 – Q&A

About the Presenter

Dmitri NesterukDmitri Nesteruk is a developer, speaker, podcaster and a technical evangelist for JetBrains. His interests lie in software development and integration practices in the areas of computation, quantitative finance and algorithmic trading. He is an instructor of an entry-level course in Quantitative Finance. His technological interests include C#, F# and C++ programming as well as high-performance computing using technologies such as CUDA. He has been a C# MVP since 2009.

Posted in News & Events, Webinars | Tagged , , | Leave a comment

Living with Microsoft C++ Compiler Bugs and Ambiguities

It’s no secret that the Microsoft Visual C++ compiler has lots of non-standard behaviors. What’s even more unfortunate is that those behaviors are subsequently used by different libraries. Ultimately, for a tool vendor there’s no option in not supporting all of those peculiarities. Here are a few that we’ve come across:

Eliminated Types

In addition to using C++ macros to generate actual executable code, you can exploit a Microsoft-specific peculiarity to generate comments as well. This is possible thanks to simple concatenation. Define a CONCAT macro as follows:

Now, simply concatenating two slashes together generates a // line comment:

This shouldn’t really work because the result of the ## operator must be a valid token. Similarly, you can make a block comment. However, you cannot terminate a macro comment with a macro call, only with */:

So why is this relevant? Well because, if you look at e.g., the <oaidl.h> header, you will see declarations similar to the following:

Depending on the version of the compiler, _VARIANT_BOOL will either generate a comment or a ‘variant bool’ type:

__VA_ARGS__ Chaos

Owing to a bug in Microsoft compiler’s refusal to expand __VA_ARGS__ into an argument list, the following definition is ambiguous:

Now consider the statement printf("%d\n", A_VA(1, 2));. On GCC, Clang and similar, this would correctly expand to

However, the Microsoft compiler would instead expand it to

Interestingly, Microsoft does not admit this is a bug. I guess it’s easier that way – if it’s not a bug, no need to fix it, right?

On the other hand, the Boost library is aware of this bug, so it checks explicitly whether the compiler is MSVC and, if it is, it tries to do things differently. On the ReSharper end, even though ReSharper C++ is adapted to MSVC (e.g., in terms of MSC_VER and MSC_FULL_VER definitions), we try to handle the VA_ARGS case as standard-compliant compilers which, unfortunately, leads to errors when parsing Boost.

ReSharper C++ meanwhile knows how to handle the MSVC case too, and this is precisely what we do when parsing the Microsoft standard libraries. However, if we adopt the MS-centric approach to all libraries, this would cause ReSharper C++ to fail in all sorts of cross-platform projects which are edited in VS but are built using NMake. And we cannot behave in a Microsoft-compliant way in Boost because errors occur not only in Boost itself but also in locations where those affected constructs are being used. So this is why in some Boost files ReSharper C++ pretends to be Clang and not MSVC.

Binding Rvalues to Lvalue References

This is an error according to the C++ standard, but the Microsoft compiler allows the binding of rvalues to lvalue references via an extension. Here is an example:

The code above will not compile on either GCC or Clang.

So you might think that extending support for this situation in ReSharper is not a problem. Well, it turns out, things are a little bit trickier. Consider the following code:

Which overload does main() call? The C++ standard says that some_func(Y) must be chosen, since the overload binds an rvalue to an lvalue reference, which is not allowed. But if this situation is allowed, some_func(X&) must be chosen instead. The problem is that this would make a standard-compliant program behave differently under MSVC, so in this specific case the conversion is disallowed.

So, after some trial and error, we found a proper way to handle this: we first do standard-compliant overloading, i.e., disallowing the binding of rvalues to lvalue references. Then, if and only if we fail to find a viable function, we check the overload again, this time allowing the binding to happen.

As you can see, the tricky part here is figuring out how various MSVC extensions interact with the C++ standard and the way they are implemented. Expect a blog post on them too, soon!

Dreaded Two-Phase Lookup

The C++ standard states that lookup in template code must happen in two phases:

  • The first phase happens when the code of the template is parsed. All non-dependent names (those that do not depend on template parameters) are looked up straight away.
  • The second phase occurs when the template is being instantiated and this is when all dependent names are being looked up.

So, for example, the following code must produce an error according to the C++ standard.

This code should not compile because the variable a is not a dependent name and should be found at the declaration parsing stage. However, this is not the case with MSVC, which will happily compile the code and complain only when X is instantiated and method() is called, i.e. in something like

But now things get even trickier, because if we declare a after the template declaration but before instantiation, everything works fine in MSVC, but must also fail according to the C++ standard:

It gets even more confusing when base classes are involved:

This code compiles without problem in MSVC, but should result in an error. The workaround to make the code standard-compliant is to access the variable b as:

So in ReSharper, we use the standard-compliant version of the lookup, so we show an error when accessing b without the this-> qualification:

ReSharper C++ unqualified dependent lookup error

However, a large number of programs written for MSVC adopt this style. And why wouldn’t they? After all, this seems like a very natural way to write code and, without proper compiler diagnostics, they would never have a clue that the code is not standard-compliant.

This is why we show warnings for these cases instead of errors by default. However, this behavior can be changed in ReSharper C++ settings by going into ReSharper settings (Code Editing → C++ → Inspections) and unchecking the appropriate flag:

ReSharper C++ Treat resolve errors as warnings in template code

We highly encourage everyone willing to write standard-compliant code to uncheck this flag!

In Closing

This may have been a bit of a discouraging post with respect to MSVC, but do not worry — in a subsequent post we’ll take a look at MSVC-specific constructs which, while not necessarily standard-compliant, are nevertheless interesting and often quite usable. ■

Posted in ReSharper C++ Tips & Tricks | Tagged , | 11 Comments