Quantcast
Channel: CLion : A Cross-Platform IDE for C and C++ | The JetBrains Blog
Viewing all 680 articles
Browse latest View live

CLion 2021.2.4 Bug-fix Update

$
0
0

Since rolling out CLion 2021.3 a couple of weeks ago, we’ve been working on some critical bug-fixes in CLion 2021.2. Today we are releasing a bug-fix update for it, CLion 2021.2.4.

To download this version, visit our website, update your version using the ToolBox App or from inside the IDE via a patch, or use snaps if you are an Ubuntu user.

The main highlights:

  • Fixed the Main menu so it now loads instantly (IDEA-277709).
  • Fixed the low resolution of the icons in the main menu (IDEA-283733).
  • Fixed the File mask drop-down list so it now properly displays the available masks (IDEA-236785).
  • Fixed the results tabs so that only the intended ones respond when you close them (IDEA-274154).
  • Fixed the IDE’s behavior when switching between Git branches – unexpected empty windows no longer appear (IDEA-277226).
  • Fixed a regression when opening a CMake project without an .idea folder in it (CPP-26927).

The full release notes are available here.

Your CLion team
JetBrains
The Drive to Develop


CLion Bug-Fix Update 2021.3.1 and Roadmap for 2022.1

$
0
0

On the first day of December, we released CLion 2021.3. Now it’s time to announce the first bug-fix update, build 213.6461.46. You can get it from our website, in the Toolbox App, or as a snap (for Ubuntu). You can also update via patch from the IDE itself.

DOWNLOAD CLION

Notable bug fixes included in this update:

  • Project Model:
    • Fixed a few issues with the new CMake generator UI (CPP-27260, CPP-27308).
    • Fixed broken Makefile project loading when sudo was used for the compiler call (CPP-26761).
    • Fixed the problem causing the STM32CubeIDE project build to fail if AzureRTOS middleware was used (CPP-27204).
  • Toolchains:
    • Added redirect input support for the new Docker toolchain (CPP-27595).
    • CTest is now supported for the new Docker toolchain (CPP-27589).
  • Debugger:
  • Code navigation:
    • If there are several implementations available, navigating from a declaration now takes you to the one that is part of the build configuration selected in the editor, if possible (CPP-8264).

The full release notes are available here.

Special thanks

Now that the 2021.3 EAP cycle is over, we’d like to sincerely thank all of the participants of our recently finished Early Access Program for their valuable feedback! We also appreciate the help of those who filled out the EAP surveys – the results helped us make several important decisions during this iteration. As a special thank you, we’ll be sending a special JetBrains gift box to the most active EAPers! Congratulations to:

  • Taw Moto
  • Oliver Stöneberg
  • Victor Sergienko
  • Tom Evers
  • Corey Kosak
  • Nikita Konyuchenko

We’ll email you in the next few days regarding your address and other details for delivery.

Roadmap for CLion 2022.1

We deliver dozens of bug fixes in every release, but there are times when a more systematic approach to addressing existing issues can bring significant improvements. We’ve decided that this time is now, and we’re fully dedicating the CLion 2022.1 iteration to bug fixes and making a quality release.

We reviewed the tickets submitted to our issue tracker and considered the number of votes they’ve received, the popularity of their use cases, the number of users affected by them, and some other factors. The list of issues we’ve decided to focus on is preliminary, and this is definitely not the last quality iteration, so please keep reporting the issues that bother you and prevent productive development with CLion. Meanwhile, we’d like to share the plans we have for the upcoming quality release below.

The following is only a preliminary plan and not a promise or commitment. Tasks might be changed or rescheduled for various reasons. We cannot guarantee that all of the issues listed below will be addressed in CLion 2022.1.

  1. Remote development and toolchains: CLion 2021.3 brought a native Docker toolchain and support for the new remote development workflow involving a thin client and headless remote machine. Both additions require significant effort to maintain and to address the issues and known limitations. This process significantly depends on user reports and activity, so we encourage you to give these features a try and share your feedback.
    We also plan to sort out several GDB server remote debug configurations in CLion, and we’ll add the ability to stop the process when the GDB server detaches from it (CPP-20346).
  2. Embedded systems development: We plan to address several issues with STM32CubeMX projects, finalize the serial monitor plugin, and improve the current RTOS debugging support.
  3. Project models: We want to address one of the major root causes of many support requests that come en masse several times per year – lost compiler paths in Visual Studio and Xcode toolchain updates (CPP-25667). We will search for, discuss, and consider a solution for the annoying CMake project is not loaded message warning (CPP-14062). We are also doing our best to bring colorized output to Ninja (CPP-17786).
  4. Debugger: Together with the Rider for Unreal Engine team, we’ll keep improving our own LLDB-based debugger on Windows. We’ll work on debugger performance issues and will specifically investigate cases when the debugger hangs (CPP-13354) or the IDE freezes (CPP-20491). Even if we can’t address it fully, the problem with stdout data being lost in some cases (CPP-5704) will get some attention.
  5. C++ language support, clangd integration, code analysis: We plan to further improve the accuracy of the built-in code analyzer and address Clangd crashes.
  6. Performance: We intend to address cases of high CPU usage resulting from unit test detection (CPP-19971), a freeze caused by the Usages view (CPP-8459), and other cases of IDE performance degradation.

Your CLion team
JetBrains
The Drive to Develop

CLion Bug-Fix Update 2021.3.2 With Fixes for Remote Development

$
0
0

The CLion 2021.3.2 bug-fix update, build 213.6461.75, is now available. You can get it from our website, in the Toolbox App, or as a snap (for Ubuntu). You can also update via patch from the IDE itself.

DOWNLOAD CLION

This update is focused on improving the new Remote Development functionality introduced in v2021.3:

  • Fixed the high CPU usage when idle: GTW-685.
  • It’s now possible to use Gateway to open a project by symlink: GTW-720.
  • Open classes and the placement of tabs are now preserved between sessions: CWM-4048.
  • Fixed glitches that appeared when scrolling through long lists in tool windows: CWM-3679.
  • Fixed the unclickable pop-ups: CWM-4422.
  • Added a context menu for Gradle tasks: CWM-4312.

Other fixes are listed here.

Your CLion team
JetBrains
The Drive to Develop

C++ Annotated December 2021: 2021 C++ Highlights, Thread Safety in C++ and Rust, 2022 Conferences, and More

$
0
0

We have all the December news for you in our latest monthly C++ Annotated digest and its companion, the No Diagnostic Required show.

If you have already subscribed, feel free to skip straight to the news. If this is your first time here, let us quickly take you through all the formats we offer. You can read, listen, or watch our essential digest of last month’s C++ news:

  • Read the monthly digest on our blog (use the form on the right to subscribe to the blog).
  • Subscribe to C++ Annotated emails by filling out this form.
  • Watch the No Diagnostic Required show on YouTube. To make sure you hear about new episodes, follow us on Twitter.
  • Listen to our podcast – just search for “No Diagnostic Required” in your favorite podcast player (see the list of supported players).

2021 was a great year for C++ despite the ongoing pandemic. December captured many of the year’s highlights, which we’ll cover in the Learning section. Thanks for staying with us in 2021! Inr 2022 we hope that C++23 will be successfully finalized, C++17 adoption will rise, new standards will emerge, tools will evolve faster, and more offline and hybrid events will appear. Watch the December episode to learn more:

Or, read the digest below.

December news

Language News

As usual, here’s our round-up of some of the new or updated proposals being considered by the standards committee.

Assumptions

Last month, we looked at the portable assumptions paper, P1774, which was reinvigorated with a view to making it in for C++23.

This month sees an r5 update with minimal changes – mostly just extra clarifying material added upfront in response to discussion on the mailing lists. The only outstanding concern (not captured in the paper) is about potential implementation difficulties with one compiler. The design itself seems all set to go to the polls, which should be open by the time this is published and will run until the plenary session on February 7, meaning there’s still a good chance it can make it in for C++23!

That said, there is one issue that has been raised, by way of a new paper, P2507r0. The issue is fairly subtle and won’t really matter to most people, most of the time. But, currently, the assumptions paper (P1774) specifies that the category of the expression in an assumption is an assignment expression. That’s not because assignment is a use case we specifically want to support. But in C++ there is a hierarchy of expression categories, with assignment expressions being the second most liberal, near the top of the hierarchy. Conditional expressions are more restricted, but they seem to cover everything we can think of that we would need for specifying assumptions (and even a bit more). So the thinking behind this paper is that we should specify the most conservative type of expression that meets our known use cases, as we can always expand it later, whereas reigning in an overly liberal expression category would be much harder!

On the flip side, all existing platform-specific extensions that provide assumptions capabilities today use assignment expressions! So using those is, arguably, following existing practice. And if someone uses a more creative type of expression, we may lock them out of using the new, standard, portable feature.

The good news, though, is that this issue being raised shouldn’t preclude P1774 getting voted in for now. Then P2507 could still be discussed, and applied against it, after the design freeze – even as late as a national body comment, if necessary – so there’s time!

std::execution

Another paper we’ve looked at before is P2300, “std::execution” – the spiritual successor to the executors papers. If you’ve been following this, you’ll know this is an important paper, which potentially touches on, or even underpins, several other in-flight proposals (Networking, for example).

This new revision contains 12 entries in its revision history for R3 – some small, but some more impactful. It’s good to see such active advancement on the topic, but it does seem too active, still, to make it for C++23.

There’s also a new paper, P2504r0, that could be seen as supporting material. It doesn’t actually propose anything (other than its own conclusions) but is useful background reading. It also makes some rather bold claims. From the intro, it says that it “aims at providing proof that the senders/receivers model proposed by [P2300r2] can constitute a global solution to concurrency.” By this it means that all concurrency primitives, such as mutexes and semaphores, can be expressed in terms of tasks with constraints – and that these tasks can be scheduled optimally and, therefore, be more performant than using the primitives. It then goes on to show that computations are a superset of tasks that can do more things that are useful (error handling, completion notifications, and heterogeneous composition). Since it equates computations with senders from the senders-receivers model of P2300, it concludes that everything discussed applies to that model.

In the General takeaways section it says:

“We’ve shown in this paper that computations can be used as a general mechanism for solving all concurrency problems. We’ve also shown that computations can be used as a top-down mechanism to describe concurrency; thus it provides a way for doing structured concurrency. All these can be made without compromising safety, and ensuring the maximum efficiency.”

It also states that “the programmer will no longer need to add locks into the code”, concluding that “computations solve concurrency”.

The meat of the paper is couched in somewhat mathematical terms, but nothing too heavy, mostly just set notation and terminology from logical proofs. It’s a good read, and rings true. But, while it chimes with what I have read and experienced in some functional languages, I’m not enough of an expert in the field to be able to say, with authority, that these claims are met. Let’s see where the discussion goes.

Coroutine generators

A new paper that dropped this month is “std::generator: Synchronous Coroutine Generator for Ranges” (P2502r0). If that title sounds familiar, it’s because we discussed it last January. But didn’t we just say it was a new paper?

The acknowledgements section should clear things up:

“I’d like to thank Lewis Baker and Corentin Jabot, whose P2168 I looted shamelessly for this proposal. This paper is presented as a new revision of their unpublished D2168R4 for continuity of design.”

So we could consider this a fork of P2168 – closer to an r5, perhaps.

Since we’ve covered it before, just a quick recap: C++20 coroutines are a language feature without the necessary library support. A fully featured reference library exists in cppcoro, from Lewis Baker, and the expectation was that we’d get much of that added for C++23. That’s been happening, but at a slower pace than expected (presumably due to the pandemic). This proposal introduces support for the most fundamental type of coroutine – the generator. A generator is a way of continuously yielding values to the caller. In a way, it is one of the simplest (useful) coroutines. But the fact that this paper runs for 28 pages (up from 23 in P2168) suggests that making that work correctly is not as simple as it sounds. A particular complication is support for recursive coroutines – a coroutine that yields a generator of the same type. The paper gives examples of why this is useful, and why it’s hard to support – and support efficiently.

I’m hoping this is in time for C++23, but it’s cutting it close!

Monadic operators for std::expected

Here’s another new paper that might sound familiar. That’s because I’ve been talking about this one for a few years now! Ever since the monadic operations for std::optional were first proposed (and recently adopted into C++23), it was only a matter of time – and someone writing the paper – that the same operations be proposed for std::expected. Now that std::expected is in its final stages of wording review, it seems like a good time to kick that off.

Again, we’ve covered it more than once before, but to recap: these operations let you sequence operations (functions or lambdas) that return values wrapped in std::expected as if they returned the expected value, and shuffles the error handling off to a dedicated step, usually at the end. This is closer to the exceptions model, with the control flow pushed into the infrastructure, albeit with a bit more syntax. But along with that syntax you also get determinism and more flexibility in how you want to handle things. And in cases where the error path is common enough, this approach should perform better, too (at least until we get something like P0709).

C++ at the end of 2021

On the very last day of 2021, Bartlomiej Filipek posted the final report about the state of C++ and its ecosystem in the past year. Among the many things mentioned there, it’s worth highlighting the final picture of the C++ standard conformance in the major compilers. 2021 saw three standards being worked on in parallel: C++17 was finalized in all three major compilers, work on C++20 is in progress, and C++23 is already in active development in terms of compiler implementation.

Regarding the standards, you can learn about the major things that are coming or at least highly possible in C++23 from the article. While the overall changes happening to the language are mostly welcomed by the community, Nicolai Josuttis commented on the report to highlight a problem mentioned by some members: the lack of bug fixes in the language, and raw features being added without the possibility to fix them because of backward compatibility.

2021 also became a year of tooling in the C++ ecosystem, with many significant updates to popular tools such as IDEs, compilers, and code analyzers, as well as continuous work on the implementation of modules and the growing popularity of Clang-based tools. Compiler Explorer had a great update in 2021, too, adding support for compiling multiple files with CMake.

The report also lists the notable C++ books that were published, the online and hybrid events that happened, and the various community surveys that were held in 2021. The author also presents the results of the survey he ran among his blog audience earlier in December. Check it out to learn about the latest C++ trends such as how quickly the standards are being adopted and what tools C++ developers prefer.

C and C++ development on Windows: encoding issues

An interesting article was published at the end of 2021 dedicated to encoding issues on Windows and in standard C and C++ libraries. It first discussed the fact that Windows internally uses UTF-16 and a so-called narrow API that has limited access to the system. As a consequence, the standard library (and your portable software on Windows) cannot handle anything but ASCII. There is a way to force a process to use UTF-8 as the process code page on Windows now, but the approach still suffers from issues with UTF-8 input and output.

Another issue with cross-platform C/C++ development is that Windows distinguishes between text and binary streams, but macOS and Linux do not. However, the standard also specifies that standard input, output, and error are all open as text streams, and there’s no portable method to change the stream mode to binary. This leads to performance degradation when reading and writing standard streams.

As a bonus, the article introduces the libwinsane library, which can help address these problems.

Thread safety in C++ and Rust

This article by Josh Haberman compares the thread-safety approaches in C++ and Rust. It maps C++’s thread-safe and thread-compatible terms to Rust’s Sync and Send traits. The major difference lies in the thread-safe approaches taken. Rust models this within the type system, and so it gets checked by the compiler. It might look a bit unusual that Rust forbids shared mutable access at the language level, but allows interior mutability where mutations are allowed on an immutable reference. But when a different view on the terminology is taken, it starts looking more logical. Would you prefer adopting Rust’s approach, or do you feel C++ terms are less confusing and more comfortable to use?

The evolution of lambdas in C++14, C++17, and C++20

We love Jonathan Boccara’s overview posts, which always help sort out our understanding of whatever topic he writes about. This one about C++ lambdas is no exception.

The article goes over the key milestones in how C++’s lambdas have evolved through the recent language standards. It starts with C++14, which introduced default and template parameters to lambdas, added the ability to use generalized capture, and made it possible to return a lambda from a function. With that, C++ lambdas became very similar to regular functions and thus very usable in everyday coding.

With C++17, lambdas became available in contexts evaluated at compile time because they could now be declared constexpr. Later, with the advent of C++20, that enabled many STL algorithms in the constexpr mode, as you could easily manipulate collections at compile time. The second big enhancement from C++17 in lambdas was the ability to capture a copy of *this. It seems minor at first glance, but it helps avoid Undefined Behavior and thus unwanted crashes that might happen when the object is already destroyed while a lambda is still capturing a pointer to it.

Finally, C++20 improved lambdas to make them look more like regular functions, now with the classic syntax to define templates and to capture a variadic pack of parameters.

The evolution of functions in modern C++

We’ve talked about lambdas, but what about functions in modern C++? Marius Bancila has overviewed the evolution of this major development element. It doesn’t go deep into each function type or function-related features, but works as an overview and a convenient index of each function addition appearing in C++11, C++14, and C++20.

The post begins by listing the very basic functions that C++ developers had before C++11.

C++11 made functions more expressive with things like function templates with a variable number of arguments, an alternative syntax for the return type and decltype, more special member functions, and default and deleted specifiers. At the same time, constexpr functions that are evaluated at compile time shifted the focus from programming at runtime to programming at compile time.

C++14 generalized functions. A return type was no longer required as compilers were taught to deduce the return type from the return expression(s) present in the function body.

Finally, C++20 advanced the earlier function-related features with immediate functions that must be evaluated at compile time, as well as (un)constrained abbreviated function templates whose function parameters could be defined with the auto specifier.

The post also touches on coroutines and lambdas, but really briefly.

How do you think lambdas and functions might evolve further in standards like C++23 and C++26? Please share your perspective in the comments!

C++ conferences in 2022

While the pandemic is in full swing and having a big impact on the conference circuit, the major C++ events are trying to move to hybrid or return to their offsite venues.

  • C++Now, the most academic event in the C++ world, will be happening May 1–6, 2022, in Aspen, Colorado. It will be fully on-site. Submissions are now open through January 30.
  • C++ on Sea, a recent event born just before the pandemic set in, also plans to run in-person. The dates have been announced (July 4–7, 2022) along with the keynote speakers (Hana Dusíková, Kevlin Henney, and Jason Turner). If you are interested, submissions are open through February 6.
  • C++ Russia, the biggest event in the Russian C++ community, with talks in both English and Russian and quite a few international experts invited, is staying online in 2022. The event has been moved to June 6–9, 2022. The CFP is now open and will be running through March 21.
  • C++ North, a brand new Canadian C++ conference, will start for the first time ever on July 17–20, 2022, in Toronto, Canada, as a fully offline event. Sean Parent and Kate Gregory are confirmed as the first speakers, while the general CFP will start January 24.
  • ACCU 2022, an event about C++ and much more, will be running a hybrid format April 5–9, 2022. Keynotes will feature Guy Davidson, Hannah Dee, Patricia Aas, and Titus Winters. The rest of the program should be announced soon.

Embedded software development in Visual Studio

A new blog post from Visual Studio describes the updated workflow for embedded development, specifically using the Azure RTOS sample. All the tools necessary for this project can be quickly installed using vcpkg, thanks to the manifest file located in the project folder. Next, the blog post covers code editing, building, deploying, and debugging, while highlighting some of the Visual Studio features. If you have an .svd file from the MCU manufacturer, you can use this description of peripheral registers to get the peripheral register view right in Visual Studio. Another useful view in this case is RTOS Object Views, which has now been added to VS.

CLion 2022 plans and roadmap for 2022.1

The CLion team has decided to fully dedicate the CLion 2022.1 iteration to bug fixes and making a quality improvement release. The announced roadmap describes the key areas of focus:

  • Improvements concerning the most recently added remote development and toolchains.
  • For embedded developers, the serial monitor plugin will be finalized and the current RTOS debugging support will be improved.
  • A handful of the most annoying issues will be addressed in project models, debugger performance, and Clangd stability.
  • Users can also expect many improvements to the IDE’s overall performance.

Unreal Engine development on Linux with Rider

A couple of years ago JetBrains started working on a dedicated IDE for developing Unreal Engine games. These efforts targeted Rider, which was known earlier as a C# and Unity IDE. With support for the native uproject project model, we managed to turn Rider into an Unreal Engine IDE, gradually making it available for each of the three major platforms. Windows was the first OS, macOS was added in April 2021, and finally Rider came to Linux in December 2021.

The feature set is similar to what’s available on other platforms, including:

  • A smart editor that is knowledgeable not only about C++ in general, but also about the UE reflection mechanism, UE-specific code checks, and the UE naming style.
  • Integration with Unreal Editor, which makes it possible to run and debug the game directly from Rider.
  • Support for Blueprints, which uses valuable information parsed from BP files to enhance the way code is represented in the Rider editor.

Check out Rider on Linux for your Unreal Engine game development and let us know about your experience. We appreciate all of your feedback, good or bad!

Anastasia Kazakova

Twitter: @anastasiak2512

As a C/C++ software developer in Telecom and Embedded systems, Anastasia was involved in research estimating the broadband capacity of home networks and participated in launching 4G networks. She is now the Product Marketing Manager for JetBrains C++ tools.

Phil Nash

Twitter: @phil_nash

Phil is the original author of the C++ test framework Catch2. As Developer Advocate at SonarSource he’s involved with SonarQube, SonarLint, and SonarCloud, particularly in the context of C++. He’s also the organizer of C++ London and C++ on Sea, as well as co-host and producer of the cpp.chat podcast. More generally, Phil is an advocate for good testing practices, TDD, and using the type system and functional techniques to reduce complexity and increase correctness. He’s previously worked in Finance and Mobile and offers training and coaching in TDD for C++.

Parameter Hints and Type Hints

$
0
0

In this video, we show how CLion’s parameter hints and type hints help with reading and understanding C++ code, using a practical example. Parameter hints give the developer useful additional information about function calls, while type hints show deduced types in many different contexts. We show the various available features and configuration options that will help you work more effectively with hints in CLion.

00:00 Intro
00:19 Sample application
01:12 Parameter hints
02:30 Emplace_back example. Hints for non-const references
03:07 Disabling parameter hints and Exclude List
04:01 Type hints for deduced types
04:44 Type hints for structured bindings
04:55 Type hints for templates
05:09 Type hints for functions with auto return type
05:27 Type hints in lambdas
05:56 Settings

Your CLion team
JetBrains
The Drive to Develop

CLion Starts the 2022.1 EAP

$
0
0

The CLion 2022.1 Early Access Preview program starts today!

As promised in the roadmap announcement, we’ll be focusing on quality in this release cycle, addressing the most annoying and painful bugs, and improving existing workflows. But you can also expect some new features, which we started working on earlier, to become available. We’ll be grateful to learn how well they work for you so we can make them even better before the public release.

Give the free EAP builds a try and let us know what you think about the changes! Share your feedback in the comments or submit it to our issue tracker.

CLion 2022.1 EAP

Build 221.3427.90 is available from our website via the Toolbox App or as a snap package (if you are using Ubuntu). Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

DOWNLOAD CLION 2022.1 EAP

Here are the main highlights:

New remote development capabilities are bundled

The new remote development mode was announced in the 2021.3 versions of our IntelliJ-based IDEs, including CLion. The main idea behind remote development is to use a powerful remote machine to execute all IDE operations and to build, run, and debug code – all while running the IDE on a local thin client. A remote host is a physical or virtual machine hosting the source code and running the headless IDE (i.e. CLion) to perform most of the IDE functions.

As we described in the release blog post, CLion 2021.3 didn’t bundle this functionality because there were several major workflow issues at the Beta stage, and JetBrains Gateway needed to connect the remote server and start a local thin client. But with 2022.1 EAP, the new remote development capabilities are now bundled in CLion! To access JetBrains Gateway, select Remote Development on CLion’s Welcome screen:
CLion welcome screen

Build tool in Toolchains settings

In Toolchains settings (Settings/Preferences | Build, Execution, Deployment | Toolchains) you can now configure any build tool to be used with a toolchain. Previously, the make tool was required in this field, which you could later substitute with Ninja, for example in CMake profiles. This worked, but was definitely inconvenient and non-intuitive. Now you can specify the build tool in the Toolchains settings. In default toolchains, Ninja is used when nothing is configured:
Build Tool in Toolchain

Enhanced UX for CMake generator

We’re continuing to make the CMake generator easier to use in CLion. Two options are worth noticing in the generator dropdown list in CMake Profile settings, one new and one updated:

  • Use default – for new projects, this option now takes the build tool configured for the toolchain selected in the corresponding CMake Profile. The actual value is also shown in the dropdown option.
  • Let CMake decide – this option means CLion won’t be forcing any CMake generator explicitly, meaning that CMake will decide what generator to use. By default, CMake uses the CMAKE_GENERATOR environment variable to determine the CMake generator (CMAKE_GENERATOR).

CMake generators

CMake profiling

Have you ever wondered why it takes a long time to reload your CMake project? CMake 3.18 introduced a way to generate trace information while generating a project. You can use it to inspect the tracing results and identify specific places in your CMake scripts that can be improved.

CMake uses Google’s Trace Event format for the results. To enable the tracing, simply add two flags to the CMake command: –profiling-format=google-trace and –profiling-output=<path>. CMake will then generate a JSON file with the tracing results under the specified <path>.

What’s new in this CLion EAP is that it can now help you run the tracing and visualize the results:
CMake tracing results

Use one of these two ways to enable the CMake tracing:

  1. Manual: add –profiling-format=google-trace and –profiling-output=<path> to the CMake options in your project.
  2. Automatic: click Add event tracing to CMake in the CMake tool window:Add event tracing
    CLion will search for configurations with the CMake profiling option (with the -event-trace suffix in the name). If none are found, the IDE will copy the profile that is currently selected and add the required options:
    CMake tracing profile

Once the CMake profile is reloaded, CLion will show a notification suggesting to open the profiling information:

CMake tracing results ready

In the profiling tool window you can:

  1. On the left-hand side: inspect the process ID and thread ID for the CMake reload process.
  2. In the center: inspect the flame chart showing the stack trace of the CMake process in each time frame during the CMake reload.
  3. On the right-hand side: explore the details of the selected event. Details include event (function) name, duration, function arguments, and where the function is located in CMake scripts.

Namespaces in the New C++ Class dialog

When creating a new C++ class, you can now specify the namespace where you’d like the new class to be located. You can write in any existing or nonexistent namespace (which will be created along with the new class), a nested namespace, or even an anonymous (unnamed) namespace if you enter a blank space in this field:

New C++ Class dialog

The field has basic validation checking the identifier is a valid namespace name or a blank space.

Preview for intention actions

CLion’s intention actions cover a wide range of situations, from warnings to optimization suggestions. As you probably know, you can click the bulb icon or press Alt+Enter to open the list of suggestions and select an action from the list. Starting with this EAP, now you can also see a preview of the result of the selected action:
Intention preview

To activate it, press Ctrl+Q (on Windows/Linux) or F1 (on macOS).

The preview is not available for all intention actions. If an intention action is too complex and the preview cannot be generated, you will see the intention action’s description. The preview is available, however, for DeMorgan laws, invert if condition, merge if-else, merge nested if, Clang-Tidy, MISRA, Clazy, split declaration and assignment, split into separate declarations, and a few others.

Once activated, the preview will appear every time you open the list of available intention actions. To close the preview, press the shortcut again while the list of intention actions is open.

Grouping by the qualified name in the Structure view

In the Structure view, elements can now be grouped by the qualified name:

Structure view

Select between grouped view or plain view with fully qualified name included in each element name.

Clang-Tidy settings

Clang-Tidy settings in CLion can be configured in Settings/Preferences | Editor | InspectionsC/C++ | Static Analysis Tools | Clang-Tidy. This EAP build comes with an updated dialog for checks configuration that simplifies the enable/disable process, by providing a tree with all the checks:
Clang-Tidy checks

Speed search helps you find the required checks quicker – just start typing the name you are looking for when the dialog is in focus. Click the Visit Help Page icon (planet symbol) to navigate to the documentation on the LLVM website describing the check in detail.

Docker toolchain

When working with the Docker toolchain, you can now provide additional container settings, such as port and volume bindings, and others:
Docker toolchain settings

Notable fixes

As this is a quality-focused release, we’d like to highlight some of the important fixes we’re delivering in this EAP build:

  • Project model:
    • Conflicts in CLion when setting build directory in CMake presets have been resolved (CPP-26755).
    • Makefile projects are now loaded correctly when using the Cygwin toolchain (CPP-27539).
    • CLion can now successfully find the compiler executable for compilation database projects with the Windows system toolchain (CPP-27732).
  • Embedded:
    • Fixes for STM32CubeMX projects (CPP-15489, CPP-23278, CPP-26942).
    • FreeRTOS GCC/Posix port is now supported and thus enables FreeRTOS debug on Linux (CPP-26898).
    • Macros now work in Embedded GDB Server configuration fields (CPP-27286). CMake variables now work for Embedded and Remote run/debug configurations (CPP-19627).
  • Dynamic analysis:
    • For remote toolchains, Valgrind and Sanitizers previews are now displayed correctly for out-of-project header files (CPP-23847).
  • Refactorings:
  • Clangd:
    • Added __cplusplus and other predefined macro names to built-in macro completion (CPP-50).
    • Postfix completion now considers formatting options (CPP-25966).
    • Fixed several causes of Clangd crashes, and merged some of the recent changes from the LLVM upstream branch.
  • Editor:
    • Introduced various fixes for inlay hints (CPP-27854, CPP-27628, CPP-27151).
    • Added parameter info for structs literals (CPP-2075) and initializer list (CPP-15143), as well as make parameter info more informative for emplace, emplace_back, make_unique, and make_shared functions.

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop

CLion Bug-Fix Update 2021.3.3 With Fixes for Unit Testing and VCS

$
0
0

The CLion 2021.3.3 bug-fix update, build 213.6777.58, is now available! You can get it from our website, in the Toolbox App, or as a snap (for Ubuntu). You can also update via patch from the IDE itself.

DOWNLOAD CLION

Here are the highlights:

  • C++ unit testing:
    • Run configuration and run gutter icons were fixed and now work correctly for Doctest v2.4.7 and later.
  • VCS:
    • The Git Branches popup displays its data correctly again (IDEA-286795, IDEA-285766).
    • Fixed the issue that was disabling the Rebase button in the Rebase dialog (IDEA-282538).
  • Fixed issues with YAML files (IDEA-247565, IDEA-264436).
  • Editor:
    • On macOS, ⌘N opens the Generate popup as expected when File | New is invoked (IDEA-286810).
    • Fixed a cosmetic UI issue in the Find In Files dialog (IDEA-284849).
  • The IDE has stopped suggesting unwanted plugin installations (IDEA-283690).

The full release notes are available here.

Your CLion team
JetBrains
The Drive to Develop

CLion 2022.1 EAP2: Remote Development with Space Dev Environments, More Accurate Code Analysis, New Formatter Options for Structured Bindings

$
0
0

Hi,

A new CLion 2022.1 EAP build is available now! If you haven’t yet tried the new version, now is a good time to do so. Build 221.4165.77 is available from our website via the Toolbox App or as a snap package (if you are using Ubuntu). Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

Those who are already using EAP1 can apply a patch to update to EAP2.

DOWNLOAD CLION 2022.1 EAP

Remote development with Space dev environments and projects warm-up

Have you already tried the new remote development workflow in CLion? You can learn how it works in CLion in this blog post. In the first 2022.1 EAP we bundled the Gateway functionality into CLion. And now another valuable part of the new remote development workflow has been added to CLion. Cloud dev environments featured in Space can now be used with CLion. Dev environments are virtual machines running on the Space cloud. You can now use these machines for software development instead of your local one. Check out these blog posts for more technical details and a brief video overview:

By using dev environments you can:

  • Speed up onboarding with standardized environments.
  • Get a ready-to-use IDE in seconds with prebuilt snapshots.
  • Centralize the management of your dev environments.
  • Save resources with automatically hibernating dev environments.
  • Work on several tasks simultaneously.
  • Collaborate on code with your teammates.

The warm-up feature now also works for CLion. Learn more in our documentation.

Notable fixes and enhancements

  • For library files, CLion no longer shows the This file does not belong to any project target notification (CPP-27963).
  • C++ code analysis is now more accurate and faster. Just to mention a few improvements:
    • “Condition is always false/true” checks now work correctly with types and narrowing conversion (CPP-18639, CPP-27516).
    • CLion no longer marks fields as unused if they have nontrivial destructors (CPP-22442).
    • False warnings in template class are removed (CPP-27004).
    • Several performance optimizations were applied to Data Flow Analysis.
    • Incorrect Clang-Tidy results that occur when the WSL toolchain is used are now fixed by executing Clang-Tidy inside the WSL itself.
  • C++ code completion:
    • The completion for template class members was improved (CPP-2115).
    • The completion in range-based loops with templates now works (CPP-20122).
    • When completing macros with variadic arguments, the name of the first argument is now present in the completion item (CPP-27818).
  • Inlay Hints:
    • Hints for array indices can now be disabled if you don’t need them:Array Hints setting
    • Hints for emplace, emplace_front and emplace_after were added.
  • Formatter:
    • New formatter options for structured bindings were added to Spaces.Spaces in structured bindings
      and Wrapping and Braces sections:
      Wrapping in structured bindings

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop


C++ Annotated January 2022: C++20 to Eliminate Runtime Bugs and Achieve Better Design, Full Test Coverage, and a New QML Compiler

$
0
0

We have all of the January news for you in our latest monthly C++ Annotated digest and its companion, the No Diagnostic Required show.

If you have already subscribed, feel free to skip straight to the news. If this is your first time here, let us quickly take you through all the formats we offer. You can read, listen, or watch our essential digest of last month’s C++ news:

  • Read the monthly digest on our blog (use the form on the right to subscribe to the blog).
  • Subscribe to C++ Annotated emails by filling out this form.
  • Watch the No Diagnostic Required show on YouTube. To make sure you hear about new episodes, follow us on Twitter.
  • Listen to our podcast – just search for “No Diagnostic Required” in your favorite podcast player (see the list of supported players).

Watch our January episode or read the digest below:

January news

Language news

This month was the WG21 plenary call. These are the events that usually happen on the last day of a physical gathering of the committee, and are where the official votes for what is adopted into the working draft for the next standard take place. This time the event was especially significant as it was deemed the cutoff deadline for new designs for C++23.

There were 17 papers approved for adoption in this session. 14 of them were library papers, of which 6 related to ranges – an indication of how important ranges are in the C++23 priority list. In fact there is an overarching paper, P2214, “A Plan for C++ Ranges”, that spells out what we were aiming to get in for C++23, and at this point a significant chunk has made it.

Let’s have a look at a couple of the ranges papers that were just adopted.

P2441R1 – “views::join_with”

Many higher-level languages, Python for example, give you an easy way to take a collection of items and join them up into a single item, usually a string. For strings, in particular, this is usually accompanied by the ability to specify a delimiter, such as a comma.

In C++20 we got the first part with the views::join range adapter, but this lacked the delimiter feature. views::join_with fixes that, and it works for any range, not just collections of strings.

P2387R3 – “Pipe support for user-defined range adaptors”

Talking of ranges, the built-in range adapters can be composed using the pipe operator. For example (from cppreference):

    auto const ints = {0,1,2,3,4,5};
    auto even = [](int i) { return 0 == i % 2; };
    auto square = [](int i) { return i * i; };
 
    for (int i : 
             ints | 
             std::views::filter(even) |
             std::views::transform(square)) {
        // …
    }

In general, this allows a transformation where a call to a range adapter f(x) can be written as x | f. Functional programmers will be familiar with this type of transformation, usually as a general language feature.

But if you supply your own range adapters, this didn’t work out of the box in C++ … until C++23.

Now, with a little support code to hook up to some customization points, your own range adapters can take part in this functional lifestyle.

P0323R11 – “std::expected”

We mentioned this just last month, so it’s not unexpected, but std::expected has now been officially voted into the working draft for C++23.

We won’t go over it again this month – refer back to last April’s coverage for more details – but it’s noteworthy because this was the only library feature accepted in this time that was labeled a “large” feature.

P0627R6 – “Function to mark unreachable code”

This proposal solves the halting problem. Well, it’s more of a workaround, really. There are times when the compiler can’t predict with certainty that a particular line will never be reached, but the programmer does know (at least in the absence of bugs). That may have consequences – from noisy compiler or static analysis warnings, to suboptimal code as the compiler has to generate redundant checks and other unnecessary code. A common example might be a switch statement over an enum which is either exhaustive or which the programmer knows will only ever be reached with certain values.

Many compilers have had implementation specific intrinsics to allow the programmer to annotate this for some time. For example, __builtin_unreachable() is provided by GCC, Clang, and Intel C++. In Visual Studio you can write __assume(false).

As a valuable, widely provided-by-extension feature, it makes sense to provide a standard (and therefore portable) version. That’s what this paper specifies: std::unreachable().

But there are some extra considerations. As hinted at by the Visual Studio workaround, there is an interplay between reachability and assumptions. In fact it turns out you can implement either in terms of the other! Whether you spell it __assume(false), __builtin_assume(false), [[assert axiom: false]], or [[assume(false)]], it’s easy to see how “unreachable” can be implemented in terms of assumptions. But the other way around works, too:

if( !condition )
  std::unreachable();

This, effectively, has the same meaning. So was it a race between this paper and P1774 (Portable Assumptions) as to which one would make it in first (a race that P0627 appears to have won)? Not necessarily. There is still a lot of value in more accurately expressing your intention. This applies to human readability, of course, but also to the compiler! Section 2.1 of P1774 cites an example where using __builtin_unreachable() pessimizes a certain case with GCC, whereas compilers that have something like __builtin_assume() are more optimal.

But until P0627, or a similar proposal, is adopted into the standard, std::unreachable may form the basis for a portable assumptions workaround.

C++20 to eliminate an entire class of runtime bugs

Cameron DaCamara wrote a great story about eliminating runtime bugs caused by format specifiers. This problem was occurring in MSVC code when printing compiler error messages that are enhanced with extra information passed via format specifiers.

The problem with format specifiers is that they are not type-checked in the call to error. Users might get into trouble with the runtime error if the compiler’s developers mistakenly pass the wrong argument or don’t pass one at all.

The compiler team looked into this problem, initially armed with C++14/17. The solution was to check the format specifiers at compile time. This approach fell short, however, because it was impossible to make an error call constexpr and pass template parameters to it. It required updating the whole codebase, which was unacceptable.

With C++20, MSVC developers acquired new language tools to protect themselves from these runtime issues. They took a similar approach to the one taken in the fmt library, which didn’t require touching any call sites. Consteval is used for the constructor of the user-defined type to evaluate strings at compile time. As a result, the compile team managed to identify about 120 problematic calls. Sounds like a great number covered!

Interestingly, in the comments there was a discussion about why we shouldn’t restrict types by using a concept. As the blog post author noted, concepts help you make better guesses about the semantics of the types being passed into a function. In this case, the semantic is stored in the format string itself, so compile-time constraints work better. What about you? Do you also have any similar stories?

100% test coverage

Let’s dig into a discussion about testing and test coverage. According to the JetBrains Developer Ecosystem Survey from 2021, 30% of developers don’t write unit tests for C++. The rest are doing some unit testing, but are they reaching full coverage? This article is not a technical overview of lcov, gcov, or any other coverage tools; it’s more like an invitation to a discussion. It raises questions about what full coverage actually means. Does it mean 100% of code lines? There are various reasons why you might want to exclude parts of the codebases from such reports, and tools often include the option to do so. Is it a report from one specific run? When collecting coverage reports, you’re not limited to just one test loop. Reporting can cover an entire testing pipeline, where unit and integration test reports are merged.

Who benefits from this? Participants in the code reviews and QA engineers. They see which parts are more vulnerable and require a deeper dive in manual testing or a more careful review process. Full coverage doesn’t replace manual testing, but rather directs it.

Do you aim for full coverage in your projects? Share your thoughts in the comments.

How to iterate through std::tuple

A new article from Bartlomiej Filipek on the C++ stories blog talks about the techniques used to run through all of a tuple’s entries. The example used to demonstrate the approaches is a simple printTuple function.

A tuple has a variable number of elements, which you can access via std::get by index or by type as a template parameter for the function call. Values and types are set at compile time. We also want to build a compile-time loop to solve our printing task.

The first approach presented in the article saves some typing by passing decltype to deduce the type of tuple itself, but the indices are still passed manually. To automate the latter, the author suggests using std::index_sequence (built over std::integer_sequence) and std::tuple_size. Based on that, a nice stream output function is written.

In the next chapters, the author promises more complicated examples allowing value transformations. A paper on a compile-time loop is mentioned, which could make life much easier, but it’s unlikely to appear in C++23.

Migrating to a safer API with {fmt} 8.x

A new blog post from Victor Zverovich discusses a few interesting examples of when migration to {fmt} 8.x eliminated several classes of bugs and made the code safer. The main drivers are the compile-time format string checks, which are now enabled by default, and stricter pointer diagnostics and [[nodiscard]], which are used to annotate formatting functions.

[[nodiscard]] annotations help with a family of cases where the format string is created but not used by mistake. Compile-time format string checks help in many cases, like when the format specifier is not implemented. This is now detected at compile time, which
is much better than throwing a format_error upon running. Check out more interesting cases in the original article!

Finding the second largest element in a range

This article might sound like the type of test task assigned during a job interview process. At the same time, it’s a typical problem that many programmers have to solve in the course of their everyday lives. There could be various requirements, and it’s also interesting to discuss how they affect the solution.

If you can’t modify the range, the two obvious solutions are as follows: (1) Iterate through the range while updating two variables to store the 1st and 2nd largest values, or (2) Iterate twice via std::max_element function call (the first iteration finds the maximum element and the second one looks for the maximum element that is smaller than the element found during the first iteration, with the first call using a lambda as a third argument to the function).

If you are allowed to modify the range, you can make the code a lot shorter by partially sorting the range. (3) The std::nth_element function guarantees that the element placed in the n-th position is exactly the same element that would occur in this position if the range was fully sorted. For us, n is equal to 2 and the sorting should go from biggest to smallest. Alternatively, (4) you can use std::partial_sort, which sorts the range from first to middle arguments while leaving the latter half of the arguments in an unspecified order. We only need to sort the two largest elements in the range. The partial sorting approaches, however, fail if the maximum element appears multiple times.

The article also includes the performance measurements for the described solutions.

The evolution of std::equal_range

The evolution of std::equal_range described by Jonathan Boccara in his blog post shows how a good design can be achieved. The main issue with the good old C++98 equal_range is that it returns a pair of iterators. This pair is a “range” only because of the specific implementation. The semantic of the range is missing.

A few improvements can be made to the code with auto from C++11 and structured bindings from C++17. The solution looks much better but the abstraction is still wrong.

It wasn’t until we started using C++20 where equal_range was finally able to return an object that is a range. The Ranges library, finally living up to its name in this version of C++, provides the necessary function.

Compile time code generation and optimization

There are situations where you want to specify something in a different language at compile time, and have it executed at compile time, such as a DSL. In his blog, Jonathan Müller shows how you can achieve that. The sample case is a compiler that can parse a Brainfuck program given as a string literal, and the execution also happens at compile-time. The goal is to show the power of constexpr.

The solution starts with a VM operating on an array of instructions. The program is known at compile time so the array size is fixed. The first implementation has parsing happening entirely at compile -time, but execution at runtime. The execute function is then converted from the switch-case operator to tail recursion. Then the author made an observation that the arguments of the recursive call can be computed at compile time, so the recursive execute function calls are turned into template instantiations with the program passed as a template parameter. Now everything happens at runtime and the generated assembly (the links to Compiler Explorer are provided in the blog post) confirms that everything works as expected.

The new Qt Quick Compiler

In January, the Qt blog introduced a series of articles on one of their new projects – the Qt Quick Compiler for QML. The goal is to increase the compilation speed so that QML runs at a speed close to native. It’s important to remind the readers that QML is an interpreted language, so there is a performance cost. The technology preview has started for Qt commercial customers, targeting not only the compiler but also tools that will help transform the code to achieve better performance.

Among other blog posts on the new compiler, the one about the technology is especially interesting. The path to a new Qt Quick Compiler started from compiling QML scripts into C++ and using QML engine’s private API. The next step was targeted at specifically optimizing the run-time aspect. For this, a caching approach was used and the byte code representation for each function and expression was stored and bundled into the binary. Interestingly, this worked better than C++ code generated by the old Qt Quick Compiler. The reason is that, compared to the extremely generic code generated, the interpreter comes with the run-time knowledge of the Qt metatype system, so it can reduce the type checking overhead.

The third step was obvious, following the logic and the problem described earlier of code being too generic. A way to declare the QML types together with the C++ types backing them was suggested, as well as the possibility of providing type information in function signatures. Later, the CMake API for building QML modules was introduced to sort out the QML file locations.

All of these ideas were later joined in the new Qt Quick Compiler, which consists of two parts:

  • The QML Script Compiler to compile functions and expressions in QML files of an application into C++ code.
  • The QML Type Compiler to compile QML object structures into C++ classes.

Qt Quick Compiler scheme
The performance benefits of the new approach have been measured and the results were published in the Qt blog. Even if you are not a Qt user, the general approach of speeding up the compilation and run time of the interpreted language is interesting.

JetBrains C++ tools start the 2022.1 EAP

We decided our first CLion and ReShaper C++ releases this year will be focused on quality improvements and bug-fixing. The first EAPs with many fixes are already published and you can try them for free. Here’s a brief summary of the major things delivered in the preview builds:

  • CLion: The team is polishing the new remote development functions, has enabled support for Space dev environments, made toolchains and CMake profile settings more flexible, added a built-in preview for intention actions (DeMorgan laws, invert if condition, merge if-else, merge nested if, Clang-Tidy, MISRA, Clazy, and some others), introduced a new UI for Clang-Tidy settings, and added an option to provide additional container settings, such as port and volume bindings, for the Docker toolchain.The only new tool integrated into the CLion 2022.1 EAP is CMake profiling. If you’ve ever wondered why it takes so long to reload your CMake project, you can now try and find the answer with CLion’s help.
  • ReSharper C++: Development is currently being taken in two main directions – sorting out and addressing the most annoying issues found in the product, and polishing the Unreal Engine support. To help you develop your Unreal Engine code faster, ReSharper C++ 2022.1 now adapts its features to the currently used version of Unreal Engine. For example, it now offers only the applicable reflection specifiers in code completion.
  • Rider: If you are developing with Unreal Engine, this is an important piece of news! Unreal Engine support has been added to Rider 2022.1 EAP and will be released within the first major update of this year. C++ and Blueprints support, hundreds of code analysis checks, instant navigation actions, refactorings, code hints, native support for the uproject model, and more are all now available in the Rider EAP on all three major platforms. The blog post also comes with a short FAQ on why CLion isn’t used for UE, and how the Unreal Engine support in Rider relates to the Unreal Engine support in ReSharper C++.

And finally, what would you remove from C++, if not for ABI stability?

This reddit thread received lots of comments recently as it raised a popular question: Pretend for a moment that you don’t have ABI stability in C++. In that situation, what would you remove from C++ or fix in the language? The question probably arose in response to many ABI-related talks and discussions, where speakers proved just how much we care about ABI stability by listing the changes that were rejected because of it.

Several long threads in comments suggest an integer conversion to bool and even implicit conversions of any kind. It seems that many developers recognize a need for this but prefer to have more manual control over it. In the case of literals, where the need for implicit conversions is recognized by many, there is still a suggestion to improve things – make literals have unique types implicitly convertible to suitable integer types. A related idea shared in the comments was to cancel the old C-style cast.

Another popular idea is making variables const by default, or at least having that for function parameters. Another suggestion mentioned many times in the comments is to reject fallthrough by default in switch-case operator.

I personally love the “list of denials”:
Quote from the reddit thread
I was surprised that undefined behavior was only mentioned after several hours of discussion in the comments.

What would be your answer to this question? Share in the comments.

Anastasia Kazakova

Twitter: @anastasiak2512

As a C/C++ software developer in Telecom and Embedded systems, Anastasia was involved in research estimating the broadband capacity of home networks and participated in launching 4G networks. She is now the Product Marketing Manager for JetBrains C++ tools.

Phil Nash

Twitter: @phil_nash

Phil is the original author of the C++ test framework Catch2. As Developer Advocate at SonarSource he’s involved with SonarQube, SonarLint, and SonarCloud, particularly in the context of C++. He’s also the organizer of C++ London and C++ on Sea, as well as co-host and producer of the cpp.chat podcast. More generally, Phil is an advocate for good testing practices, TDD, and using the type system and functional techniques to reduce complexity and increase correctness. He’s previously worked in Finance and Mobile and offers training and coaching in TDD for C++.

CLion 2022.1 EAP3: Enhanced Type Hints, Fixes in Auto-Import and Navigation, and More Flexible Reset Options in Embedded GDB Server Configurations

$
0
0

Hi,

The new CLion 2022.1 EAP build, 221.4501.161, is now available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

Those who are already using EAP2 can apply a patch to update to EAP3.

DOWNLOAD CLION 2022.1 EAP

The main highlights:

  • Inlay Hints improvements:
    • CLion now displays an accurate type hint for dependent types (CPP-28259):
      Hints for dependent types
    • When returning a lambda that returns a lambda, the return type hint is now displayed (CPP-28308).
    • CLion now displays a user-friendly wstring alias as a type hint for the std::basic_string<wchar_t> type:
      wstring alias in hints
  • We’ve fixed a bug that was causing the auto-import pop-up to appear multiple times after the auto-import suggestion had been accepted (CPP-6267).
  • When clicking on the left-gutter navigation icons, navigation now happens immediately when there is only one viable option to navigate to. No context menu is opened in this case.
  • The Embedded GDB Server configuration can now reset the device at different stages: Before or After the download (i.e. flashing MCU ROM or writing to RAM), Always (both before and after), or Never:
    Embedded GDB server
  • Several exceptions were addressed in this build.

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop

CLion 2022.1 EAP4: Debugger Enhancements, CUDA-GDB, and Valgrind with Docker Toolchain

$
0
0

The new CLion 2022.1 EAP build, 221.4906.7, is now available from our website, or via the Toolbox App. Please note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

Those of you already using EAP3 can apply a patch to update to EAP4.

DOWNLOAD CLION 2022.1 EAP

CUDA debugger in CLion

The CUDA-GDB debugger can now be used in CLion. We’ve fixed issues with the empty variables view in the debug tool window and with the No symbol in current context error (CPP-19915). The work on the debugger for CUDA is still not finished, however, the fix should allow you to at least do basic debugging and report any issues to our issue tracker.

To make it work, you’ll need to specify the cuda-gdb binary in the debugger setting of your current toolchain:
CUDA-GDB

And use the following compiler option: add_compile_options(-G) to add CUDA debug symbols.

Debugger UI updates

In CLion 2021.3, the debugger UI got an update. The feedback we received was mostly positive, but a few things irritated some users. We’ve decided to address these issues. In the layout settings of the debugger tool window there are two new options available:

  • Separate Watches: enables you to use a separate tab with watches.
  • Show Tab Labels: enables you to use debugger tool window tab names.

Other improvements

  • We’ve fixed a regression for Boost.Test v1.69.0 on Windows, which resulted in no test run icons and no text macros highlighting.
  • The option to show both decimal and hex values in the debugger now works for LLDB on Windows (Build, Execution, Deployment | Debugger | Data Views | C/C++ | Show integers as hex values and Display alongside the original value).
  • Valgrind now works with the Docker toolchain.
  • Following the Clang-Tidy settings update introduced in EAP1, the MISRA settings were also updated to provide you with a convenient visual representation of the MISRA C 2012 and MISRA C++ 2008 check lists:
    MISRA settings

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop

CLion Bug-Fix Update 2021.3.4 With Fixes for MinGW Toolchain and the Rust Debugger

$
0
0

The CLion 2021.3.4 bug-fix update, build 213.7172.20, is now available. You can get it from our website, in the Toolbox App, or as a snap (for Ubuntu). You can also update via patch from within the IDE itself.

DOWNLOAD CLION

Here are the highlights:

  • Bundled LLDB on Windows was fixed to allow the debugging of Rust code (CPP-28633).
  • MSYS2 MinGW, starting with version 9.0.0.6373.5be8fcd83-2, is now supported in CLion (CPP-28403).
  • Fixed an issue with the remote SSH connection in cases where Python isn’t installed on your computer or there is no python in path /usr/bin/env (IDEA-281405). This issue also caused significant performance CPU usage and a hang (CPP-27880).
  • Fixed the IDE’s behavior on macOS when using Cmd+Shift+[ and Cmd+Shift+] to switch between Big Sur tabs (IDEA-261595).
  • Fixed the Ctrl+arrow shortcut when used in the terminal on Windows. The caret now jumps to the next word as expected (IDEA-283023).

The full release notes are available here.

Your CLion team
JetBrains
The Drive to Develop

CLion 2022.1 EAP5: Setting to Reload CMake Profiles Sequentially, Fixes in Quick Documentation and Toolchains, and a Project Generator for Rust

$
0
0

The new CLion 2022.1 EAP build, 221.5080.1, is now available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). Please note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip). Those of you already using the EAP4 build can apply a patch to update to EAP5.

DOWNLOAD CLION 2022.1 EAP

Here are the main highlights:

  • Toolchains:
    • CLion now supports MSYS2 MinGW, starting with version 9.0.0.6373.5be8fcd83-2 (CPP-28403).
  • Project model:
    • By default, CMake profiles are reloaded in parallel in CLion. In some cases, this might cause issues when reloading CMake. To resolve this, we’ve added an option to reload CMake profiles sequentially. You can find it in Settings/Preferences | Advanced Settings | CMake:Advanced Settings
    • Fixed a syntax highlighting issue in Makefile (CPP-24010).
  • We’ve implemented several enhancements for code completion (CPP-27347, CPP-27465, CPP-28265).
  • In the Quick Documentation pop-up, we’ve fixed the incorrect formatting of the macro replacement when there is a using keyword in the macro (CPP-28558).

If you are interested in trying the Rust language, a new stub project generator for Rust projects will help you even if you don’t have the Rust plugin installed. It will help you install the plugin
New Rust Project w/o a plugin
and gracefully navigate you through project creation:
New Rust project with the plugin

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop

CLion 2022.1 EAP6: CMake Presets, Improved CMake Scripts Formatting, and Other Fixes

$
0
0

The new CLion 2022.1 EAP build, 221.5080.52, is now available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). Please note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

Those of you already using the EAP5 build can apply a patch to update to EAP6.

DOWNLOAD CLION 2022.1 EAP

CMake updates

CLion now automatically creates CMake Profiles for configure presets (this was only available for build presets before). This change makes the configuration process easier and lets you remove redundant build presets.

Configure presets in CMake

CLion now also works with the --preset argument passed to the cmake command. The data from the preset is loaded into build type, toolchain, and build directory settings.

CMake v3.22 has been bundled into CLion.

CLion now notifies you when something has changed in the environment and the changes require clearing CMakeCache.txt and reloading the project:

Environment change

The notification is typically shown after you update Xcode on macOS and your compilers are no longer available at their previous paths. Something similar might also happen for MSVC and MinGW.

CMake scripts are now formatted more accurately:

  • if() .. endif(), else() and elseif(), endforeach(), endfunction(), endmacro(), and endwhile() are aligned correctly.
  • It is now possible to fold blocks for these commands.
  • Brace pairing and code block highlighting are available for these commands as well.

CMake Formatter

Other highlights

The build also includes fixes for the following issues:

  • False positives occurred in Data Flow Analysis for function calls located inside parentheses (CPP-28122).
  • The auto keyword was highlighted incorrectly when a trailing return type was used (CPP-28440).
  • A wider context than necessary was considered by the Rename refactoring when renaming a local variable (CPP-23257).
  • Various issues in code completion (CPP-27816, CPP-27318, CPP-22156).
  • Broken highlighting and run icon for Boost.Test 1_69_0 (CPP-28254).

The full release notes are available here.

DOWNLOAD CLION 2022.1 EAP

Your CLion team
JetBrains
The Drive to Develop

CLion 2022.1 Goes Beta

$
0
0

The Beta version of CLion 2022.1 is now available. Build 221.5080.93 is available for download from our website, via the Toolbox App, or as a snap package (for Ubuntu). No license is required, as this build is still free to use.

CLion Beta

DOWNLOAD CLION 2022.1 BETA

Here are the main highlights:

  • C++23:
    • Added support for uz / z literal suffixes.
    • Added support for preprocessing directives elifdef and elifndef.
  • CUDA-GDB:
    • Fixed an issue with the inline watch in the debugger when switching between cuda/non-cuda frames (CPP-28501).
    • Removed Version unknown warning for CUDA-GDB.
  • Minor fixes in the Quick Documentation pop-up and in the Inspection settings.

You can find the full release notes here.

Your CLion team
JetBrains
The Drive to Develop


CLion 2022.1 Release Candidate

$
0
0

We are approaching the release, and the CLion 2022.1 Release Candidate is now available for download. To install CLion 2022.1 RC (build 221.5080.169), download it from the website, update from our Toolbox App, or use this snap package (for Ubuntu). You can also update from CLion 2022.1 Beta via a patch.

You need to have an active subscription or start a free trial to use CLion 2022.1 RC.

CLion RC

Updated Inlay Hints settings

CLion makes code easier to read thanks to parameter and type hints shown in the editor. The settings in Settings/Preferences | Editor | Inlay Hints are now enhanced with some explanations and code examples:
Inlay Hints

Other improvements

  • A new setting was added to Settings/Preferences | Advanced Settings | CMake that allows the user to disable CMake Presets integration. It’s enabled by default, which means CLion will create CMake profiles by default for each CMake configuration and build preset found.
  • CLion can now correctly highlight the CUDA __managed__ keyword.
  • Type hints for iterators were improved (CPP-28696).

The full release notes are available here. Give the RC build a try and report any problems you find to our issue tracker.

DOWNLOAD CLION 2022.1 RC

Your CLion team
JetBrains
The Drive to Develop

C++ Annotated March 2022: Function vs. Type, Serialization in C++, DWCAS, C++ Modules in Visual Studio

$
0
0

We have all of the March news for you in our latest monthly C++ Annotated digest. Read the monthly digest on our blog and subscribe to C++ Annotated emails by filling out this form.

Language news

C++ Committee news

February’s virtual plenary was the official feature freeze date for C++. Since then, it has become noticeably quieter around the C++ Standards Committee. During the last couple of months, the Library Evolution Study Group has been working on various fixes to existing language features that have been improved for C++23, such as ranges and formatting. They’ve also been polishing the API of new features already accepted for C++23, in particular mdspan, which is now looking really good. The Language Evolution Study Group is similarly focused on various smaller bug fixes for language features.

We now also definitely know that we will not be getting executors or networking in C++23, two of the four items that were originally prioritized for C++23 according to the “overall plan for C++23” proposal. The three language features mentioned in that plan (reflection, pattern matching and contracts) are also nowhere near ready yet. As a result, the largest core language feature that is actually going to land in C++23 is deducing this. C++23 was never going to be as large a release as C++20 was, but it also seems that the pandemic and the need to move all standardization work from in-person to online meetings significantly hampered progress.

During the last couple of months, I (Timur) was mostly active in the Core study group that finalizes the wording for language features, where my paper on portable assumptions is now in the final stages of wording review. I am firmly expecting that it will be voted into C++23 at the next plenary session. I also participated in the Contracts study group (SG21), which is currently rather stuck on the question of whether or not the expressions inside a contract annotation should be allowed to have side effects, and what exactly would happen if they did. Various opinions exist, and it will take more work before we reach a consensus and can formulate a specification, but hopefully this will happen in time for C++26. The current state of this work is now being tracked in the newly established Contracts Working Paper.

Expect the standard committee work to remain relatively quiet for the next few months. We are now finalizing all outstanding fixes for the July 2022 online plenary session. This is where we will finalize the C++23 wording for the committee draft, which then goes out for review by the individual national bodies.

Learning

SFINAE, overload resolution, and a surprising error

A new blog post at C++ stories highlights an interesting aspect of SFINAE. The sample used in the article performs the basic operation of printing a tuple via the stream output operator. The custom operator throws a surprising compiler error when printing of the '\n' symbol is called. And even more surprisingly, the code doesn’t work for std::tuple_size_v<TupleT> but works when using std::tuple_size<TupleT>::value inside the implementation. The author digs deeper into the reasons why std::tuple_size_v<TupleT> doesn’t work for TupleT=char. An interesting discovery here is that the immediate context matters.

While the compiler recognizes immediately whether std::tuple_size<char>::value is valid or not, in the case of std::tuple_size_v<char> it has to look at the variable template declaration. And this is not part of the immediate context but a side-effect. Errors in such side-effects are treated as hard errors, not SFINAE errors. There are more examples of the same situation in the article, followed by the links to examples in Compiler Explorer. Feel free to play with them and explore this surprising phenomenon. Have you run into any cases like this during your own development? Let us know in the comments!

Saturating_add vs. saturating_int – new function vs. new type?

In his new blog post, Jonathan Müller discusses a trade-off between implementing the desired behavior by writing new functions and following the OOP principles by defining new types capable of such behavior. The basic example used for the experiments is arithmetic with saturation instead of overflowing arithmetics. When dealing with integer addition, should we write a new function that sums up the arguments or implement a new int type with such characteristics?

The post author describes both solutions and discusses the pros and cons of each. For example, if you solve the problem by writing a new function, then you can’t rely on known operators and have to use nested calls, thus making the code less readable. In this case, generic code is also impossible out-of-the-box. You’ll also run into problems trying to store an additional state or do extra work without updating the whole type.

Enforcing volatility is a good example of when updating the type helps to guarantee a specific behavior. Like you add volatile to the pointer type to avoid unnecessary and incorrect compiler optimizations.

But creating a new type isn’t ideal either. A new type is essentially different from the original one. You need to constantly cast to change the behavior. And you still experience issues in generic code.

There is no ready-to-use generic answer in the article. The problem is laid out and solutions are discussed. The article even highlights a few approaches to solving the problem inside the language itself. It’s up to you to decide which solution will work better for your specific case.

Metal in C++ with SDL2

You probably have heard about Metal, a graphics API from Apple. While the typical examples demonstrating usage scenarios usually rely on the Apple’s ecosystem (ObjectiveC/Swift and XCode), this new blog post shows you how to create a working sample using C++ and the C++ specific toolset like CMake and Conan.

The idea is to use Metal-cpp, a low-overhead C++ interface for Metal that helps developers add Metal functionality to graphics apps, games, and game engines that are written in C++. The library is added via CMake. And SDL2, which helps create a window and draw in it using Metal, is installed via Conan. The trick is then to use a bit of Objective-C++ to link the metal device to the corresponding view.

In the end, you get a minimal running Metal application. And some tips for compiling metal shaders.

Automatic Serialization in C++ for Game Engines

Serialization is an important functionality of any game. It’s essential when players decide to stop, postpone the game for a while, and then resume later. In practical terms, it means any game object, character, scene, etc. should be stored to the disk and then restored back. The article discusses how to perform serialization on your own for games written in C++.

It discusses the problem of storing pointers and references, which can’t be saved in the way that every other value is saved. The address should be preserved, but since this is impossible, more complicated procedures are regularly used. They often require a two-pass or some complicated indirection method, and the saving of an additional map.

Of course, the root of the problem is that C++ still doesn’t bring reflection to the developers. So you always have to add special code to your classes to get it. The example implementation in the article is based on preprocessor macros and helps avoid adding serialization and deserialization functions manually to each class.

DWCAS in C++

Timur Doumer’s latest article is dedicated to lock-free data structures that rely on double-width compare-and-swap (DWCAS) CPU instruction. The experiment and the research performed by Timur shows that, in the end, if you want to have a std::atomic that portably uses DWCAS (for example, in your C++ library) instead of silently adding locks into your code, your only option is to implement your own std::atomic for all relevant target platforms, or to use a third-party library that does it for you.

The blog post contains a simple example, and the resulting instructions generated by the compiler are inspected in the compiler explorer. And the results are really surprising!

With Apple Clang, everything works as expected for Apple Silicon and for Intel targets. It breaks on Linux, however. For Clang, there is a way to fix this by passing a certain compiler flag. But that’s not a solution for the portable library that Timur wants to build. For GCC, things don’t work as expected, even with the flag. It’s no better on Windows. DWCAS instructions are not guaranteed by MSVC. The only explanation Timur could find is that fixing std::atomic would constitute an ABI break. This is really a sad consequence of ABI stability over performance priority.

Check out more explanations and a detailed example in the original article.

Tooling

Experimental support for C++ modules in CMake projects with Visual Studio

The Visual Studio team released an announcement introducing C++ modules support with CMake and Visual Studio generator. Modules is a new feature of C++20 which still lacks proper support in tooling. And despite so many blog posts having already been written about the benefits that modules bring to C++ developers, it was still practically impossible to use them. Now there is finally a way!

Visual Studio 2022 17.2 Preview 2 has experimental support for C++ modules in CMake projects. It’s now limited to the Visual Studio (MSBuild) generator only. Which means the default Ninja generator should be changed to Visual Studio for all configurations. The blog post shows you how to do this: modify your project’s CMakePresets.json or edit the CMake settings with Advanced configuration.

The blog post is not a tutorial on how to switch to modules. There are other posts from the Visual Studio team about that. However, it shows how to start with modules by selecting a proper CMake version, setting a Visual Studio generator, and creating a module interface unit file in the Visual Studio UI. The basic sample demonstrates how to export entities and use them in other source files and module interfaces.

CMake 3.23 released

At the end of March, the new version of CMake was released. Among other things, the new version got an update for CMake Presets. And the new include field is especially useful as it allows files to include other files. A file can be included multiple times, but the include cycles are not allowed, of course.

An interesting detail about this feature from the published documentation: If CMakePresets.json and CMakeUserPresets.json are both present, CMakeUserPresets.json implicitly includes CMakePresets.json, even when no include field is used.

Another thing to note is that while files directly or indirectly included from CMakePresets.json should be guaranteed to be provided by the project, CMakeUserPresets.json may include files from anywhere.

Qt Creator 7 released

March was the month when Qt Creator 7 was released. The language engine got a significant update:

  • Clangd backend is used by default now.
  • It uses LLVM 14 for C++ support.
  • C++17 is preselected in the new project wizard as a default C++ standard.

CMake support got an update too:

  • New Run and Stop CMake buttons to reconfigure the project easily.
  • CMake options now distinguish Initial Configuration and Current Configuration in the UI, which makes it easier to understand how the settings were inherited.
  • Help links for CMake options were added to the context menu when called on an option.

CLion 2022.1 EAP news

CLion 2022.1 is going to be released soon. The release candidate is already published. This update is geared toward quality improvements and enhancing the existing workflows rather than adding new features. Here are the main directions for the fixes which made it to CLion 2022.1:

  • CMake Presets integration was updated. CLion can now generate CMake profiles for configure presets (this was previously possible for build presets only). CMake 3.22 is bundled. CLion also comes with the enhancements for CMake code formatting and folding. And there is one brand-new feature that we began developing a long time ago and hadn’t finalized until now – just in time for the current release. This is CMake Profiling. A built-in visualizer will help you find weak places in your CMake scripts that take significant time.
  • The CUDA-GDB debugger can now be used in CLion. Some users have tried it in CLion before, but a few issues were present which prevented it from working correctly. Now they are fixed.
  • In code analysis, there are plenty of fixes that make the analysis in CLion more accurate, as well as updates to Clang-Tidy and MISRA settings and a new intention preview.
  • Another area where fixes for accuracy were introduced a lot during this release cycle is Inlay Hints, i.e. hints in the editor for parameters and types.

There are many other fixes, which you can find looking through the EAP webpage.

Anastasia Kazakova

Twitter: @anastasiak2512

As a C/C++ software developer in Telecom and Embedded systems, Anastasia was involved in research estimating the broadband capacity of home networks and participated in launching 4G networks. She is now the Product Marketing Manager for JetBrains C++ tools.

Phil Nash

Twitter: @phil_nash

Phil is the original author of the C++ test framework Catch2. As Developer Advocate at SonarSource he’s involved with SonarQube, SonarLint, and SonarCloud, particularly in the context of C++. He’s also the organizer of C++ London and C++ on Sea, as well as co-host and producer of the cpp.chat podcast. More generally, Phil is an advocate for good testing practices, TDD, and using the type system and functional techniques to reduce complexity and increase correctness. He’s previously worked in Finance and Mobile and offers training and coaching in TDD for C++.

Timur Doumler

Twitter: @timur_audio

Timur Doumler is Developer Advocate for C++ products at JetBrains. Timur is an active member of the ISO C++ standard committee, co-founder of the music technology startup Cradle, and a frequent conference speaker. He is passionate about clean code, good tools, low latency, and the evolution of the C++ language.

CLion 2022.1: A Quality-Focused Release

$
0
0

CLion 2022.1 is now available! It is focused on quality improvements and enhancements for existing features and workflows like remote development, Docker, CMake Presets integration, and more. It also brings a brand-new CMake Profiling ability that helps you visually inspect why your CMake project may be taking a long time to reload. Code analysis and in-editor type and parameter hints have been tuned to work better and more accurately with modern C++.

CLion 2022.1 released

To update to the new version, you can use the Toolbox App or a snap package (on Ubuntu), download the installer from our website, or apply the patch update to upgrade from version 2021.3.

DOWNLOAD CLION 2022.1

Enhanced in-editor experience

For this release we’ve polished many CLion features that make your coding experience more comfortable, easy, and productive. We focused on their flexibility and accuracy regarding the modern C++ language.

Inlay hints

Parameter and type hints help you read and maintain your existing codebases with ease. The extra information is shown right in the editor and helps with parameter names in function calls and deduced types.

We’ve implemented a number of fixes to make inlay hints in C++ code more accurate, for example:

  • CLion now displays a user-friendly wstring alias as a type hint for the std::basic_string<wchar_t> type.
  • CLion now displays an accurate type hint for dependent types.
  • CLion 2022.1 offers better hints for the emplace, emplace_back/emplace_front, and make_unique/make_shared functions.

Emplace hints

In CLion 2022.1 we’ve enhanced the settings in Settings/Preferences | Editor | Inlay Hints with some explanations and code examples. You can now better understand the cases where the hints are shown and tune the settings to your preferences. Hints for array indices can now be disabled if you don’t need them. Previously this was not possible.

Code analysis

Because code analysis is a key part of the IDE, we’ve been working to make it more accurate and easier to configure, and to make its notifications more informative.

The Clang-Tidy and MISRA settings in Settings/Preferences | Editor | Inspections | C/C++ | Static Analysis Tools were reworked to make the process of configuring checks easier. A new visual representation includes a tree with all of the checks. Speed search helps you find the checks you need faster – just start typing the name you are looking for when the dialog is in focus.
Clang-Tidy checks

For Clang-Tidy, the dialog also links to LLVM documentation to help you learn about the checks in more detail.

It’s much easier to improve your code when the suggestions from the IDE not only name the problem and suggest the fix, but also show how the selected fix will transform the code. That’s why we’ve added a preview for intention actions:
Preview for Intention Actions

For Clang-Tidy, the issue causing incorrect results to occur when the WSL toolchain was used has been fixed by setting Clang-Tidy to execute inside the WSL itself.

New C++ Class dialog

When creating a new C++ class, you can now specify the namespace where you’d like the new class to be located. You’ll find a new field dedicated to this in the dialog:
New C++ Class

Structure View popup

Structure View helps you navigate through the current file in just a few clicks. Sometimes you want the elements there to go in the same order as in the original file, but sometimes you want them to be grouped by the qualified name. There is now a dedicated toggle in the dialog that allows you to switch between these modes.

Formatter

New formatter options for structured bindings were added to the Spaces and Wrapping and Braces sections:
Formatter options

More powerful CMake support

CMake is a first-class citizen project model in CLion. In this release, we focused on the flexibility of configuring CMake in CLion, as well as improving the CMake editing experience and adding profiling support.

CMake presets and CLion profiles

CMake 3.19 introduced CMake Presets, a universal way to configure CMake and share the configurations within your team. It’s still young and is evolving quickly, with many approaches being tested and then later updated based on feedback from people using them in real projects. CLion’s support for CMake Presets is also evolving. We now create CMake profiles for configure presets. CLion uses CMake profiles to run and debug your application, but it previously only created them for build presets. Configure profiles allow redundant build presets to be removed in many cases.

If you don’t want CLion to create profiles from presets at all, a new setting that controls this was added to Settings/Preferences | Advanced Settings | CMake | Enable CMake Presets integration. Another setting there is the option to set CMake profiles in CLion to reload sequentially. You might need this in the event of non-trivial connections between profiles that make parallel reload (the default in CLion) impossible:
Advanced CMake settings

CMake generators

In the CLion toolchain, you can now configure any build tool of your choice, not just make. Now if you need one specific build tool for all profiles working with a specific toolchain, you can simply configure it in the toolchain itself instead of configuring it in every CMake profile. In CMake profiles, this means that the Use default option is selected in the generator field. Another new value in the generator setting is Let CMake decide. With this option selected, CLion won’t favor any CMake generator explicitly, and CMake will decide which generator to use instead.
CMake generators

CMake formatting

Formatting support in CMake scripts now helps with if() ... endif(), else(), elseif(), endforeach(), endfunction(), endmacro(), and endwhile() commands and their corresponding blocks. They are correctly aligned, pairing braces are highlighted, and the blocks can be folded:
CMake formatting

CMake profiling

Have you ever wondered why it occasionally takes a long time to reload your CMake project? CMake v3.18 brought the new ability to profile your CMake scripts and inspect the traces to find the answer. CLion now offers support for this feature, including the automatic creation of profiling configurations and the visualization of tracing results. Learn more.
CMake Profile

Wider range of debugger options

If you develop with CUDA, you’ll be happy to learn that we’ve fixed some critical issues that were preventing you from using CUDA-GDB in CLion. To make it work, you’ll need to specify the cuda-gdb binary in the debugger setting of your current toolchain and use the following compiler option to add CUDA debug symbols: add_compile_options(-G).

For developers on Windows using the Visual Studio C++ toolchain, CLion comes with the LLDB-based debugger maintained by the JetBrains team. The hex value view in this debugger has been fixed and you can now enable it using Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++ | Show integers as hex values and Display alongside the original value.

Toolchains

With container-based development being massively popular, Docker toolchain is one of the most widely used in CLion. In version 2022.1, we’ve improved its integration in CLion:

  • The Valgrind Memcheck tool for detecting memory-usage problems now works with the Docker toolchain.
  • In the toolchain settings you can now provide additional container settings, such as port and volume bindings.

Docker toolchain

Another big story is remote development. In the previous release, CLion got support for the new remote development workflow with the thin client. This support is now getting some enhancements and is available from the Welcome screen – you no longer need to install any additional gateway software, as it’s now bundled in CLion:
Remote dev bundled
Cloud dev environments featured in Space can now be used with CLion to speed up onboarding, access a ready-to-use IDE in seconds, and manage your development resources efficiently. Learn more about Space dev environments.

That’s it for now! We encourage you to give CLion 2022.1 a try. If you have an active subscription, you can update today. Otherwise, we invite you to start your free 30-day trial to check out the new features and see what you think!

DOWNLOAD CLION 2022.1

Your CLion team
JetBrains
The Drive to Develop

ACCU 2022 Trip Report

$
0
0

From April 6-9, 2022, I attended ACCU 2022, the 25th edition of the ACCU conference, in Bristol, UK. It was only my third in-person conference post-COVID (after CppCon’21 and ADC’21). It felt very special to be back in Bristol after a three-year break, and it felt as good as ever to be among real people again. With all COVID restrictions now lifted in the UK, this was the first event on the C++ conference circuit that truly felt like it was back to normal. There was no social distancing or any other measures to impact the conference experience, and the vast majority of attendees were not wearing masks.

For me, ACCU has a special place in the C++ calendar for many reasons. First, ACCU is known for its exceptionally friendly and nice community, including folks who have been attending ACCU regularly for a decade or more, but also being especially welcoming and approachable to first-timers. This year was no different – it was great to be back meeting old friends and making new ones.

ACCU 2022

ACCU is also special in that it is not only about C++ (although it has a large proportion of C++ content), so you also get content on other technologies and non-technical talks about soft skills and other interesting things. The quality of the talks is very high and the size is just right: bigger than “small” conferences like C++Now, but not as big as CppCon or MeetingC++, so you still get the chance to meet and talk to most attendees.

In pre-pandemic times, I would usually expect about 400 people at ACCU. This year however, we only had about 150 people on site, so it was noticeably quieter than usual (although the vibe was as positive as ever). In addition, there were about as many people attending online, as the conference was fully hybrid this time, with three on-site and two online tracks and the option for online attendees to watch the on-site talks and ask questions.

The organizers went to great lengths to make the online component of the conference really enjoyable, including recreating the whole conference venue (Bristol Marriott) online inside gather.town. But I have to admit that I did not engage with the online component. Why spend time in video chat rooms when you are on site at the venue and have real people to interact with? Therefore, the following trip report is focusing exclusively on the on-site component of the conference.

Not only were there fewer people on-site, but also fewer booths. I spotted the traditionally present Bloomberg booth, as well as Graphcore and SonarSource booths. And we had a #include table again, which was a very popular hangout spot. Sadly, JetBrains did not have a booth this time, as the rest of my team was unfortunately unable to attend. In fact, out of all of the ACCU conferences I’ve attended, this was the first one with no JetBrains booth! One of my most memorable conference experiences was walking up to the JetBrains booth at ACCU 2017 and asking them whether they would consider hiring me, and the following year I was working behind the very same booth. I very much hope we will be back there in full strength next year, but this time I was representing JetBrains on my own.

Conference day 1 started with Guy Davidson’s keynote “Growing Better Programmers”. Guy is a good friend of mine and this was his first proper conference keynote. I have to say he did an amazing job! Speaking from many years of experience, Guy shared many great thoughts about mentoring and supporting programmers, promoting good practices, conducting helpful code reviews, being a good manager, and much more.

I missed the talks following the keynote because I was busy practicing my own talk, how to implement a lock-free atomic shared_ptr, which I presented that afternoon. Following that, I was met with the usual dilemma at such conferences: there are multiple tracks and you can only go to one. The program is so high-quality that you end up missing a lot of fantastic talks you really want to see. My talk of choice was “Zen and the Art of Code Lifecycle Maintenance”, a very deep and insightful investigation of what we actually mean by “code quality.” The talk was given by Phil Nash, my predecessor as C++ Developer Advocate at JetBrains, who now works at SonarSource.

My first day at ACCU 2022 wrapped up with a lightning talk session moderated by Pete Goodliffe. This is the true highlight of the ACCU conference: the lightning talks are usually very entertaining, creative, funny, thoughtful, and mostly not about programming at all. In between the talks, Pete tells dad jokes, and if any speaker overshoots their 5 minute speaking limit, Pete takes away the microphone mid-sentence and pushes them off the stage. It’s hilarious!

Day 2 opened with a keynote by Hannah Dee, “Diversity Is Too Important to Be Left to Women”. I was really impressed by this talk. It covered why diversity and inclusion are important, what we should do, and what we should not do, and covered it all in a way that felt extremely well-researched and backed up by data and facts. Even though this issue was already very close to my heart before Hannah’s talk, I learned about so many new things from her, like the concepts of gender role spillover and stereotype threat, how self-efficacy affects performance, the Petrie multiplier (a very simple yet powerful mathematical model), pareidolia, and more. I highly recommend this talk as a solid, approachable, and enjoyable introduction to anyone interested in the topic of diversity in tech.

Switching gears after the keynote and diving into C++ code again, I went to “C++20 – My Favourite Code Examples” by Nico Josuttis. This talk was full of interesting C++20 code. Nico started by showing various ways to use C++20 concepts and constraints in practice. Among other things, I learned that we can use a requires-clause inside an if constexpr, like this:

void add(auto& coll, const auto& val)
{
 if constexpr (requires { coll.push_back(val); })
   coll.push_back(val);
 else
   coll.insert(val);
}

This is a very convenient way to branch on the existence of a member function, something that was a lot more cumbersome pre-C++20. Nico then showed practical examples of how to use ranges, views, the spaceship operator, and other C++20 features all working together. Along the way, I also learned how to implement your own range sentinel! Of course, it would not be a Nico Josuttis talk without a healthy dose of ranting about things that the C++ standard committee has gotten wrong in Nico’s opinion: how cbegin is utterly broken, how “forwarding reference” is a bad name, how std::views::elements<0> does not work for user-defined types unless you declare your own tuple customization points before you #include <ranges> (which is quite unfortunate indeed), and so on.

ACCU is one of the conferences that offer talk slots to sponsors, but often these can be very interesting, so I went to a sponsored session during the lunch break: “The Power of Clean Code” by the SonarSource folks. I was very happy to see CLion in action there, supplemented by their SonarLint plug-in, which looks like a very powerful tool that I definitely need to check out in more detail.

After lunch, another ACCU speciality was waiting. The normal talk length is 90 minutes, but they also have 20-minute “quick talks”, usually several of them back to back. The ones I chose were very interesting and relevant explorations of “soft” topics: a talk by Björn Fahller about burnout, a talk by Dom Davis about remote working, and a talk by Joe Pascoe about how to be a good manager.

The second day finished with another round of lightning talks, followed by the C++ Pub Quiz hosted by conference chair Felix Petriconi.

Day 3 started with a keynote by Patricia Aas about software vulnerabilities, and this was another absolute highlight of the conference. Patricia took us on a fascinating time travel journey through the last two decades. Her slides were packed with interesting code examples demonstrating vulnerabilities arising from malloc, use after free, heap buffer overflow, integer operations, and printf format strings. Among other things, I learned what a “Write-What-Where primitive” is and that format strings are an almost Turing-complete programming language! Patricia’s talk ended with the thought that we would all benefit from more cross-pollination between the systems programming community, which C++ is part of, and the binary exploitation/vulnerability community.

The next talk slot had no fewer than three coroutines-related talks scheduled against each other. I decided to listen to Björn Fahller’s talk about using coroutines for asynchronous I/O on Linux and how they really help to avoid callback hell. In C++20, we got a basic low-level API with hooks into the compiler that enable the use of coroutines, but no library facilities whatsoever on top of that to actually use them. So even for the most basic coroutine example, we need to write a lot of boilerplate code by hand – the coroutine type, the promise type, and so on. This is very hard to learn and to teach, but Björn did a good job guiding the audience through the required machinery. His talk also contained references to other helpful introductory talks about C++20 coroutines, such as Pavel Novikov’s “Understanding Coroutines by Example”.

The other highlights of Day 3 for me were Kate Gregory’s “Abstraction patterns” and another talk about coroutines, this time by Andreas Weis, showing how to use them for data processing pipelines (reading a file from the disk, compressing it, and so on). With my background in audio software development, I was fascinated by how Andreas’ data pipelines were structurally virtually identical to audio processing graphs, containing sources, sinks, filters, and buffers, with data channels exchanged in between them. This makes me think (again!) that coroutines would probably be very useful in that domain, too.

In the evening, there was a third lightning talk session hosted by Pete (they were so popular this year that Pete ran out of lightning talk slots!), which was just as much fun as the others, and finally the traditional conference dinner, which I always enjoy. The ACCU conference dinner is geared towards enabling as many conference attendees as possible to mingle with speakers. Speakers remain at the same table throughout the dinner, while everyone else changes tables after every course. This is good fun and you get to meet lots of new people. In addition, there is always a theme – this year it was film.

And now we’re at the last day of ACCU! I started the morning by attending Mathieu Ropert’s “Basics of profiling”. Mathieu delivered a really good beginner-friendly introduction to profiling, why it’s important, things you need to know such as sampling profiling vs. instrumentation profiling, and more. He then actually live-demoed profiling his video game Hearts of Iron IV with the Optick Profiler, a instrumentation profiler, and Intel VTune, a very powerful sampling profiler. He explained what to look for and how to interpret what you see, and finished off his talk with useful general tips on how to optimize a C++ program. This hands-on approach including live demoing is rarely seen in conference talks, and I really enjoyed it.

Later that day I attended John McFarlane’s talk “Contractual Disappointment in C++”, which I also highly recommend. The title would suggest that the talk was about contracts in standard C++ and how we ended up not having them, but actually it was not about that at all. Instead, John talked about contracts as a programming concept, the difference between bugs and errors, different types of contracts, and other things that every programmer should think about.

Finally, it was time for the last talk of the conference: Titus Winters’ closing keynote! Titus, the author of “Software engineering at Google,” aka the Flamingo Book, decided to fully embrace his new brand and showed up on stage in a flamingo shirt. His keynote titled “Tradeoffs in the Software Workflow” was just as high-quality and thought-provoking as I had hoped and tackled really big questions for our industry such as “What is the value of the code that you write?” and “What is the value of preventing a defect?”. This is another talk that I highly recommend. In fact, all the talks I saw this year were so good that I am very impressed once again by the quality of the ACCU conference program.

Of course, in between all the talks, there was the all-important hallway track. Even though there was no JetBrains booth this time, I was still very busy talking to people about JetBrains products in general and CLion in particular. Some noteworthy interactions involved helping a CLion user figure out how to build the LLVM project in CLion (which gave me some good ideas for putting together a “CMake in CLion” tutorial) and multiple folks asking about the new “thin client” remote development mode in CLion (which is currently still in Beta, but nevertheless already very usable, so I recommend you check it out now!).

And that was it from ACCU 2022! I am really looking forward to next year’s conference, but in the meantime, I will be attending other in-person C++ events, with the next one on the calendar being C++Now in beautiful Aspen, Colorado. See you there!

CLion Roadmap for 2022.2

$
0
0

CLion 2022.1 was released a couple of weeks ago and is focused on quality improvements. It enhances existing workflows for remote development, Docker, CMake projects, and CUDA debugging.

Now it’s time to share what the team will be focusing on over the coming months and is aiming to deliver in 2022.2 (or in later releases).

The following is only a preliminary plan and not a promise or commitment. Tasks might be changed or rescheduled for various reasons. We cannot guarantee that all of the issues listed below will be addressed in CLion 2022.2.

  • Toolchains
    • For Docker toolchain, investigate and improve the performance of project loading.
  • Project models
    • GUI for CMake variables (CPP-423).
    • Quick Documentation for CMake commands (CPP-4857).
    • We are also starting our work on vcpkg integration (CPP-23248). However, we plan to spend 2022.2 on the internal prototype and won’t release anything publicly.
  • C++ language support
    • C++20 Modules support will be our primary task here. With CMake and Visual Studio generator, it’s now finally possible to use this major language feature in real-world projects. That’s why we are starting work on the C++20 modules in the CLion’s language engine.
    • Another direction is enhancing the accuracy of CLion’s Data Flow Analysis with interval analysis. For this, we’ll add support for comparisons (<, >, <=, >=) of integral types to help with assumptions like unreachable code or constant conditions (CPP-28313). On top of interval analysis, we will also build the “Array index is out of bounds check (CPP-28302).
    • We plan to continue our work on reducing the number of Clangd crashes and thus improving the overall quality and stability of the language engine in CLion.
  • Debugger
    • We’ll continue enhancing our LLDB-based debugger for the Visual Studio C++ toolchain on Windows. The same debugger is also used in Rider for Unreal Engine projects, so the work is shared between the teams.
    • We plan to test and bundle LLDB 14.0 into CLion.
  • Embedded development
    • We plan to continue working on the Serial Monitor plugin we already started earlier.
  • Dogfooding remote development
    Remote development with the thin client was released for CLion 2021.3 and bundled in version 2022.1. There are still a lot of issues and unsupported C++ specific workflows which we need to identify. We are looking forward to feedback from you, our users, while also dogfooding the new remote development within the team. For example, our Clang subteam decided to use it in their work. They will log the issues they encounter along the way, and we will collaborate with the remote development team here at JetBrains on fixing those issues during the next release cycles.

Your CLion team
JetBrains
The Drive to Develop

Viewing all 680 articles
Browse latest View live