In the C++ Foundation's 2023 Annual C++ Developer Survey, the community identified some of the top pain points when using C++ (see page 11 of the survey summary ).
As mentioned in this article, CLion can help C++ developers in many ways, let’s go through them one by one :
Manage third-party libraries
Reduce build time
Build CI pipeline
Manage CMake projects
Check your code for threading, memory and type safety issues in real time
Build a development environment from scratch
Modernize your code
Manage third-party libraries
The biggest challenge when using C++ is managing the third-party libraries that C++ applications rely on : 47% of users cited this as a major pain point. Unlike many other programming languages, C++ does not have a standard package manager and a variety of solutions are used. CLion has built-in support for vcpkg , one of the most popular C++ package managers. You can also use Conan, another popular C++ package manager, with CLion. The Conan plug-in for CLion is currently incompatible with the latest version of CLion. A fix is in progress, but in the meantime you can still use Conan with CLion because Conan outputs CLion-compatible CMake files.
find_package
CLion now provides code completion for third-party packages known to CMake .
Reduce build time
According to user feedback, the second biggest challenge is build time , with 43% of respondents citing this as a major pain point. Although CLion does not contain a compiler, but only calls the compiler configured in the tool chain (such as GCC or Clang) and cannot directly affect the build time, CMake execution steps can also be optimized using CLion's CMake analysis function. CMake profiling helps reduce the overall build time of your project by identifying the most time-consuming operations during CMake configuration and optimizing CMake scripts when necessary.
Build CI pipeline
According to the survey, the third major pain point is building continuous integration pipelines (automated builds, tests, etc.) from scratch . CLion provides many tools for this and has built-in support for all mainstream C++ testing frameworks (Google Test, Boost.Test, Catch2, Doctest, CTest). Includes dedicated run and debug configurations for tests, stapling area icons for running or debugging tests/suites/fixed routines and checking their status, dedicated test runners, and code completion for test and fixed routine classes.
In addition, there are CLion plug-ins for TeamCity , JetBrains' own automated build management and CI tools, and plug-ins for other continuous integration solutions.
Manage CMake projects
31% of users stated that their main pain point is managing CMake projects . CMake is the most popular cross-platform build system for C and C++. CLion bundles CMake and has extensive CMake integration , making the CMake project management experience smoother. CLion is equipped with a powerful editor that has complete syntax highlighting, auto-completion and quick documentation of CMake scripts; a built-in CMake debugger; for adding configurations and build types, creating CMake targets and adding them to these targets Built-in GUI support for or removing files and reloading CMake projects; CMake preset and CMake profile support; and other features.
But CMake is not the only project model supported by CLion. Managing Makefiles is also a pain point frequently reported by users. The good news is that CLion also supports Makefile projects and the Makefile language, which greatly simplifies the use of Makefiles.
Check threads in code in real time,
Memory and type safety issues
Several other major pain points reported by users are related to security , including thread safety (races, deadlocks, etc.), memory safety (boundary safety, use-after-free, memory leaks, etc.) and type safety . To identify and correct these common problems, CLion provides developers with a variety of static and dynamic code analysis options. For static analysis, CLion offers many useful code inspections, Clang-Tidy integration, and built-in data flow analysis .
CLion's Data Flow Analysis (DFA) can statically identify many sources of undefined behavior and potential vulnerabilities, such as infinite loops, infinite recursion, missing return statements, dangling pointers, potentially invalid iterators, and out-of-bounds memory accesses. DFA can operate locally within a single function or globally across an entire translation unit. In the following example, the local DFA identifies an iterator that may be invalidated by a call to vector::push_back::
In the following example, a global DFA issues a write-after-free warning through a pointer that has been deleted in another function:
For dynamic analysis, CLion is fully integrated with Valgrind and numerous Sanitizers , such as AdressSanitizer, LeakSanitizer, ThreadSanitizer, UndefinedBehaviourSanitizer and MemorySanitizer. We've also recently added better multi-threaded debugging support for tracking concurrency issues, such as parallel stack views and the ability to freeze and unfreeze individual threads during debugging .
development environment
Another pain point reported by users is the difficulty of setting up a development environment (compiler, build system, etc.) from scratch . CLion can help with this too: as mentioned earlier, CLion already bundles CMake, but it also comes with a bundled debugger, bundled MinGW on Windows, Docker support via a dedicated Docker plugin and Docker toolchain, and other features . For remote development, CLion supports JetBrains Gateway , which allows running CLion on a remote host and connecting through a thin client, as well as various other ways to build a remote development environment .
Modernize your code
Finally, migrating existing code to the latest language standards is a major pain point for 8% of users and a minor pain point for 27%. To easily migrate existing code to more modern C++ standards, CLion supports Clang-Tidy modernization checks directly in the IDE .
Original English author of this blog: Anastasia Kazakova
Live Reservation | JetBrains GameDev Day 2023
On October 13, 2023 (Friday), JetBrains will host the GameDev Day 2023 event, inviting 11 experts from different fields to give speeches, host discussions, and share professional tips for making the best games. The event will explore aspects of game testing, CI/CD, DOTS for Unity, and Apple Vision Pro development.
We will simultaneously broadcast this event on the video account and station B, and provide simultaneous interpretation of bilingual subtitles. Welcome to watch on time!
CLion related reading
⏬ Click "Read the original text" to learn more
This article is shared from the WeChat public account - JetBrains (JetBrainsChina).
If there is any infringement, please contact [email protected] for deletion.
This article participates in the " OSC Source Creation Plan ". You who are reading are welcome to join and share together.