Learn Productivity with CLion: Tips & Tricks Demo
In May 2019, the JetBrains team attended several events in Israel. We were inspired by the fantastic and welcoming C++ community in Tel Aviv, the old city of Jaffa, and Haifa. While the main goal of the trip was a brand-new conference – Core C++ (check out the trip report), we also had a great evening at the Haifa::C++ meetup and even ran our own event – JetBrains Night Tel Aviv 2019! We gave several talks there on C++ and .NET development in general and our tools in particular. In this blog post, we’d like to highlight one of those talks.
What does it mean to be productive when developing in C++? Can a tool help us become a language guru? Are there tricks my IDE can teach me to make C++ coding a bit easier? These were the questions I tried to answer in my talk – “Can You Make Me Productive with a C++ IDE?”. Today I want to share the recording of this presentation along with a few comments and timestamps that you can use to jump to the most interesting parts. You might even learn a trick or two from the talk!
There are dozens of great tools in our ecosystem, and each of them is honed to be really good at certain tasks. But gathering them all in one place and combining them inside one user environment can be tricky. This is the job for an IDE – an Integrated Development Environment, specifically designed to provide a universal cross-platform environment in which you can work with C++ in the most effective and efficient way possible. An IDE integrates tools and sources, from the project model and the debugger to version control systems, profilers, memory checkers, the built-in terminal, and more. It works both for local and remote setups, for WSL, or simply doing remote (or even on-chip) debugging.
With a powerful tool like that, you need to know how to use it. Let’s go over a few tips on how you can get the most out of CLion!
2:41 Come on, IDE, can you generate code for me? Can I sit here and have you write code for me? This is what I call productive laziness. The Generate menu (
Alt+Insert on Linux/Windows,
⌘N on macOS) will help generate getters and setters, constructors, destructors, definitions and even operators, and will override and implement functions. With another shortcut –
Alt + Enter – you can start using an entity before actually declaring it.
6:40 Update hierarchies while refactoring automatically to keep your code correct. CLion can actually propagate changes (with your confirmation, of course) to the top of the tree and then back down through all the branches.
8:00 Documentation is obviously one of the most valuable artifacts produced by developers. It helps you maintain your code and clarifies any parts that are not self-explanatory. In CLion, the Quick Documentation popup (
Ctrl+Q on Linux/Windows,
F1 on macOS) not only provides info on the function signatures and code documentation comments, but also shows inferred types and macro replacements. Documentation stubs can be generated and will be updated automatically when you update the function signature.
12:33 Highlight the proper preprocessor branch in CLion by selecting a resolve configuration in a switcher. This is the superpower it gives you when targeting several platforms in your code.
14:08 As you may know, CLion comes with dozens of static code analysis checks. Some of them come from CLion’s own language engine, others from Clang Analyzer and Clang-Tidy, and there are even more that are written by our team on top of the Clangd language engine. It can detect things like a function that hides a non-virtual function from the parent class, a format specifier that is missing the actual variable type, detailed overload resolution errors, missing C++-style casts, unreachable code, arguments being passed in the wrong order, and many more.
25:42 With its automatic refactorings, the IDE lets you make code changes safely. When refactoring the code, all the context usages are appropriately updated (not text search-based!). Watch the demo to learn how to add or update parameters via Change Signature, extract all occurrences at once, or even move members up and down through the class hierarchy.
29:03 When you develop locally but not on the target machine, you may need to debug remotely. Learn these very simple steps for configuring GDB Remote Debug in CLion. Also, read about this slightly different option in our web help.
33:44 Sometimes the whole cycle of development has to be remote, but you want your CLion running on a local machine. We call this Full Remote Mode. Check out this part of the demo to learn about configuring that and about what happens in the background when the connection is established and the project is reloaded in CLion.
36:45 Valgrind memory check integration in CLion helps you catch memory leaks in your code. Check the traces and jump easily to the source code from the tool window with the Valgrind results to vanquish the problem.
38:11 Check all possible kinds of memory issues with Google Sanitizers. Watch the demo to learn how to pass the
-fsanitize flag and enable the integration similar to Valgrind.
39:40 Profiling with CLion is possible on Linux (via perf) and Mac (via DTrace). Use flame charts, refer to the call tree, and jump to source to investigate likely performance issues in your codebase. See our web help for more details about the Dynamic Analysis tools integrated in CLion.
40:36 Unit testing is part and parcel of the development workflow, which ensures that changes you introduce do not break your code. Learn how CLion can empower you when using frameworks such as Google Test, Catch, or Boost.Test. Also check out our web help for some good practices to keep in mind when unit testing.
42:48 A few words on CMake integration. Learn about code completion, navigating via file names, live templates, and installing CMake.
By the way, the full transcript of the video (English only) is also available.
Please let us know if you enjoyed this format. Any questions, ideas, or suggestions? As usual, please voice them in the comments below!
Your CLion team
The Drive to Develop
Subscribe to Blog updates
AI Assistant Insights: Writing C++ Code With the Power of AI in CLion!
AI Assistant in CLion can generate whole code snippets for you. It uses the project context to create relevant function calls and C++ statements.
Striving For Better C++ Code, Part II: Function Summaries to Speed Up the Data Flow Analysis
This is the second blog post in the series dedicated to Data Flow Analysis (DFA) and its implementation in CLion. Read the first part here: Striving For Better C++ Code, Part I: Data Flow Analysis Basics Striving For Better C++ Code, Part II: Function Summaries to Speed Up the Data Flow Analysi…
Striving For Better C++ Code, Part I: Data Flow Analysis Basics
CLion comes with a built-in data flow analyzer, which runs constantly when you are writing your code and helps improve your code’s quality. It can reveal various code problems that might later lead to runtime issues, security breaches, and other vulnerabilities. Examples of these useful checks are c…