14 ms·
C++ Ecosystem: Compilers, IDEs, Tools, Testing
- dclusin 7y agoDidn't see any mention of any static analysis tools for C++. Any HN recommendations?
- tcoff91 7y agoCoverity is used at my company and seems to work reasonably well.
- linuxlizard 7y agoI hear about PVS-Studio often.
- account42 7y agoI only hear about PVS-Studio from their adticles that they agressively post to programming-related communities.
- jcelerier 7y ago- https://clang.llvm.org/extra/clang-tidy/ https://clang.llvm.org/extra/clang-tidy/ - cppcheck is sometimes updated also - clazy : https://github.com/KDE/clazy https://github.com/KDE/clazy
- Fronzie 7y agoNote that https://clang-analyzer.llvm.org/scan-build.html https://clang-analyzer.llvm.org/scan-build.html is another llvm-based static analyzer. It does a more deep analysis into the control flow, whereas clang-tidy does (mostly?) comparatively simpler checks on the AST.
- pnako 7y agoYou can actually run the static analysis checks from clang-tidy.
- Thieum22 7y agodirect link to cppcheck releases: https://github.com/danmar/cppcheck/releases https://github.com/danmar/cppcheck/releases
- The_rationalist 7y agohttps://github.com/facebook/infer https://github.com/facebook/infer Seems cool.
- imagiko 7y agoI'm interested in this too! I've been looking for one that can be used with arm-gcc for cross compiling on embedded platforms. What do people use in such situations?
- account42 7y agoClang has support for cross-compiling [1] without needing separate builds for each target so you should be able to use clang-analyzer and clang-tidy whit the right -target flag for your ARM platform. https://clang.llvm.org/docs/CrossCompilation.html https://clang.llvm.org/docs/CrossCompilation.html Besides that, most bugs found by static analysis are platform independent so you should be able to use any static analyzer you get your hands on as long as your code is cross-platform.
- imagiko 7y agoOh cool, thanks!
- pjmlp 7y agoI use what Visual C++ offers, which is already quite nice. Plus VC++ debug builds do bounds checking, even for [].
- wallstprog 7y agoI wrote a few posts on this topic that may be helpful: http://btorpey.github.io/blog/categories/static-analysis/ http://btorpey.github.io/blog/categories/static-analysis/
- lordnacho 7y agoGotta have Valgrind suite in there somewhere. Useful to find use-after-free and loads of other issues. Plus cachegrind and the rest of the suite.
- alfalfasprout 7y agoMassif + one of the visualizers is amazing for profiling allocations too.
- xyzzyz 7y agoThese days most people moved on from Valgrind to ASan and other sanitizers, which provide much of the same functionality with lower performance penalty.
- tomnj 7y agoValgrind's memcheck is still useful: it doesn't require recompiling, can handle external (binary-only) libraries, handles inline asm or jitted code, and provides uninitialized memory read instrumentation (yes, memsan does this, but it's tricky to set up). For me personally, I've required memcheck for applications using CUDA because CUDA and sanitizers don't play well together (for example, see https://github.com/google/sanitizers/issues/629 https://github.com/google/sanitizers/issues/629). but indeed, the sanitizers are soooo much faster :)
- pooya13 7y agoIs there a mem issue that can be caught by Valgrind but not by a compile time sanitizer?
- tomnj 7y agoSanitizers are not compile-time: they're runtime checks (aka dynamic analysis). For some strengths of valgrind compared to sanitizers, see my other comment in this thread.
- hermitdev 7y agoI love valgrind, but it falls on its face if you're dealing with more realtime aspects. In particular, dealing with high frequency trading systems. Valgrind, in of itself can through timings off in of itself to be unusable in some contexts. That said, great tool.
- ausjke 7y agoi bought clion then realized it is really only for cmake-based c++ projects, yes you can bend others to kind of work but it sucks, i hope clion can work with autoconf/makefile/cmake/whatever and stay neutral to build tools soon. still looking for some online c++11 course these days, udemy had none that looking good.
- godelski 7y agoDoes anyone know a good debugger plugin for vim? I've tried a few and found them not great. This is seriously the only thing I currently want more from vim. I keep an IDE around just for this purpose. (A debugger with support for C++ and python. Don't care if two plugins)
- big_chungus 7y agoI assume you're using cmake? For C/C++, cquery does completion (which I got working, but honestly didn't like and turned off. There are these two plugins for cmake: https://github.com/ilyachur/cmake4vim https://github.com/ilyachur/cmake4vim https://github.com/vhdirk/vim-cmake https://github.com/vhdirk/vim-cmake It would be fairly quick to put something in your vimrc to pop open a small split on the side, run a build command, and show an output. You could also probably pop open a terminal (new vim has the :term command) and maybe script that? If not cmake, it shouldn't be too difficult to replace cmake with something else. I've always found I can get better results from vim that more exactly what I want, but I've got to kind of want it and be willing to write some script to do it. The results are better, but there's more up-front investment.
- godelski 7y agoI'm more looking for a debugger rather than a compiler. Like GDB. I wouldn't call cmake or make debuggers. I have seen a few gdb plugins but at least my experience is that they are extremely wanting.
- big_chungus 7y agoWhy not just run `:term` followed by full gdb? Doesn't seem like it's worth implementing a whole other interface.
- godelski 7y agoThat doesn't enable the same marking of break points and other features you typically get from IDEs. In GDB you can see multiple lines and split your screen, so I wouldn't use :term (I'll split with tmux). But other things that IDE debuggers have are like a file list (nerd tree) and display works better (off to the side). GDB technically has all these things, but it isn't formatted nicely. I use vim to be fast and efficient (and vim plugins for IDEs SUCK, plus are bloated). Do people just not use debuggers around here?
- jackewiehose 7y agoOn emacs use: M-x gud-gdb
- alexhutcheson 7y ago"M-x gdb" gives you a more IDE-like experience with more features: https://www.gnu.org/software/emacs/manual/html_node/emacs/GDB-Graphical-Interface.html https://www.gnu.org/software/emacs/manual/html_node/emacs/GD...
- OlivierLi 7y agoNo mention of any LanguageServer implementation? I highly recommend rtags (even if it's not stricly LSP) https://github.com/Andersbakken/rtags https://github.com/Andersbakken/rtags
- xvilka 7y agoFor the C++ using ccls[1] is way better. [1] https://github.com/MaskRay/ccls https://github.com/MaskRay/ccls
- lorenzhs 7y agoclangd is really good these days (clangd-9), I suggest you give it a try. It's incredibly easy to set up if your distribution packages it. I'm using it with Emacs' lsp-mode, it's great.
- idnefju 7y agoHad so much trouble trying to get a C++ project cmake setup with opencv 4 in macOS. Until I found conan. I have been use to package managers from other languages.
- self_awareness 7y agoI've tried to use Conan, but was unable to use 'openssl', because it was named 'OpenSSL'. So, then I wanted to use HarfBuzz library, but Conan was unable to find one. Later I've found out HarfBuzz exists, but it's named 'harfbuzz'. The 'case sensitivity' bug was created in 2017, is still open. I think it's connected to a case sensitivity flag in filesystem which is used in the system. So, since 99% of Linux systems use case-sensitive fs, it's not usable on Linux.
- clappski 7y ago... I use Conan in projects with dependencies on OpenSSL on Linux and I don’t have any issues. I use the Makefile generator (because our build system is plain make + Conan). The name of the package shouldn’t impact you at all, unless I’m misunderstanding what you mean? Another example is a dependency on a package called ‘jsonformoderncpp’, which I use by ‘#include “nlohmann/blah.h”’ - the package name is arbitrary, even if you have to refer to the dependence using the package name in your build system rather than the canonical name I don’t see how that would be an issue (even with FindPackage or whatever you use in CMake)?
- otabdeveloper4 7y agoNix is the best C++ package manager at the moment, once you climb the slight learning curve.
- clappski 7y ago+1 for Conan, my favourite feature is using the deploy generator to gather my dynamically linked libs to deploy with my binaries - so powerful, and generally breaks the coupling between the distribution (and which packages it provides) and my application.
- jchw 7y agoClangd is a must have, using clangd in vscode + the Bear tool, you can get accurate code intelligence for just about any C/C++ project.
- alexhutcheson 7y agoThe worst thing about C++ is the endless sequences of choices you need to make about tooling before you even write a line of code. This is actually what made me switch to Go for personal projects - I'm a professional C++ programmer, but setting up a development environment required so many choices and so much futzing with various tools that I would spend all my energy getting set up and never make progress on the projects themselves. Go, Rust, and even Java are all way better in this department - the tools are standard enough that you only have to make a choice if you are doing something less common. I would love a Dropwizard-like bundle that just gives me a pre-set-up config with everything I need to write a C++ CLI app or daemon.
- codesushi42 7y agoEven Java? Java's tooling is top notch. IDE is awesome. Debugging tools are rawsome. Build tools can be... Well you've got choices. Workspace setup is easy
- alexhutcheson 7y agoAgreed that Java tooling is amazing. The only reason I said "even Java" here was the fact that you have to choose a build system from a handful of fairly popular options, which adds some up-front cognitive overhead to your project vs. Go or Rust.
- hermitdev 7y agoIve spent a good part of my 20+ year career wrangling c++ dependencies, and it's hard. MS has introduced vcpkg, which should make things better, closer to a pip or npm style package manner, but I haven't used it, so I have no idea how well it works.
- de_watcher 7y agoI stick to Debian/Ubuntu Linux. Its package manager is essentially the package manager for C++ from the beginning.
- batty_alex 7y ago
- m0zg 7y agoNo mention of the only build system worth using: Bazel. Fail. No valgrind/callgrid/cachegrind either. No google-perftools. No Linux `perf`. No mention of YouCompleteMe. This is not a comprehensive list, to say the least. I use all of these tools pretty much all the time working with C++.
- kd3 7y agoMicrosoft Visual Studio has the best c++ debugger. You get spoiled by it. Highly recommend it. If you are a beginner start with Visual Studio; it will make lots of things easier for you. Once Microsoft ports it to Linux the competition is fucked.
- dralley 7y agoMicrosoft still hasn't ported Visual Studio to 64 bit, so I don't expect Linux support is coming any time soon.
- arsenide 7y agoPer a StackOverflow post, the reasons for this are detailed here: https://blogs.msdn.microsoft.com/ricom/2009/06/10/visual-studio-why-is-there-no-64-bit-version-yet/ https://blogs.msdn.microsoft.com/ricom/2009/06/10/visual-stu... Is there some reason you would expect a 64-bit Visual Studio port before a Linux port?
- mrpippy 7y agoThe blog post is 10 years old, the reasoning was poor then and has not aged well. No mention of the performance benefits of extra registers, new instructions, security benefits, etc. The only advantage I can see to staying 32-bit is that Windows on ARM64 only has an x86 emulator, not x86_64. I think there’s a 0% chance of a Linux port: VS Code is the cross-platform/future dev environment for Microsoft. But I wouldn’t be surprised to hear that a 64-bit Visual Studio is coming soon to Windows.
- pjc50 7y agoThe new instructions are generally special-purpose, Visual Studio doesn't sound like an obvious target for vectorisation. Security is meaningless - VS is not on a security boundary. The memory size cost disadvantage is real, though.
- hermitdev 7y ago
- 29athrowaway 7y agoA few more: - compilers: Intel compiler - IDEs: SlickEdit, GNOME Builder, KDevelop, Eclipse, Netbeans - Build systems: Bazel, Meson - Static analysis: Klocwork, Coverity Scan - Fuzzer: American Fuzzy Lop - Memory debuggers: Valgrind, AddressSanitizer - Profilers: DTrace, VTune, Vampir - Documentation: Doxygen - Debugging (and more): edb, x64dbg - Reverse engineering: Radare, Cutter, IDA, Ghidra And rmsbolt (compiler explorer for emacs)...
- Const-me 7y ago> Visual C++ is a commercial Visual Studio IDE from Microsoft The OP failed to mention there's a freeware edition. > It provides the Microsoft Foundation Class (MFC) library which gives access to the Win32 APIs. Last time I used MFC was around 2003. Last time I used Win32 APIs was today. MFC doesn't give access to anything besides MFC.
- mrpippy 7y agoThe free (Community) edition is licensed for working on open source projects, individual developers, and up to 5 users in “non-enterprises” (< 250 PCs or < $1 Million US Dollars in annual revenue.) So covers most people, but could be a pain if you’re in a big company that otherwise doesn’t do much engineering.
- cmrdporcupine 7y agoCLion is an amazing tool -- I've purchased licenses for my personal self in the past, but my employer pays for it these days. My problem is they've done a terrible job of making it scale up to large code bases. I work on the chromium tree -- CLion is completely useless on it. I have a dual 24-core xeon with 128GB of RAM and SSD and I've given it a wackload of memory, and it becomes completely inoperable, freezing all over the place. Awful because I have such muscle memory for the JetBrains tools, and such a fondness for them. I've gone back to using Emacs, but now with Eclim. I just couldn't get into VSCode.
- gravypod 7y agoHave you tried pinning the IDE to one NUMA node? Text editors are pretty random access and will not have a fun time across numa nodes. Also, what range of CPUs is your xeon on? Buying a current-gen consumer chip could yield a huge performance uplift if it's not from this gen.
- pnako 7y agoIt's slow and freezes even on tiny projects. They're aware of the issue and apparently the next release will be focused entirely on trying to address those. At the moment that's my number one issue with CLion.
- vinayan3 7y agoI had similar issues when I included the standard library with templated data structures and googletest. The IDE would consume my entire MacBook Pro 2016. The UI froze, input would be delayed on the orders of 10s of seconds, and I can go on... I really really hope they can fix this because at my work I'm trying to get CLion working. The Codebase is quite large and I have to turn inspections off or else input freezes and won't be responsive for up to 30 seconds. It's at times unusable. When it works it's amazing but it still has some ways to go.
- AnthonBerg 7y ago> It's slow and freezes even on tiny projects. This statement is false. It's way too broad a claim to hold up. With all due respect I'd consider it harmfully incorrect. Counterexample: I use CLion to work on Cataclysm: Dark Days Ahead. It's ~360,000 lines of pretty hairy C++. It's fine. There may be conditions that make a stricter definition of the claim true. I don't know what those conditions would be. A link to Jetbrains' definition of the issue would be good.
- pjmlp 7y agoC++ Builder + VCL keeps being the only development environment where RAD and C++ really go hand-in-hand. Sadly thanks to their management mistakes and the trend of wanting everything for free, only a select few know how it actually feels in practice. C++/CX + XAML came close to it, but got replaced by C++/WinRT, which is still catching up to C++/CX tooling.
- babuskov 7y agoWhat about Qt? Doesn't it have something similar? As a cross-platform C++ Builder replacement, I have been using wxFormBuilder and wxWidgets in the past. There are some manual steps, but it let's you build a GUI quickly, hook up event handlers and then write implementation code in a derived class, so that stuff generated by GUI editor doesn't rewrite your code.
- pjmlp 7y agoNot 100% alike, because it depends on QML/JavaScript and lacks the eco-system of third party components. Thanks for the wxFormBuilder and wxWidgets reference, I always saw them as a MFC wannabe and don't have any experience with them.
- gnud 7y agoYou can still use QWidgets, which is more similar to VCL. There are third-party components (for example the open-source Qwt [0]), but probably fewer than you find for VCL :) 0: https://qwt.sourceforge.io/ https://qwt.sourceforge.io/
- pjmlp 7y agoQWidgets are stuck in desktop deployment scenarios, with QML taking front row for everthing else, something that they plan to change with Qt 6, which remains to be seen in what form it will be done. Qwt is not the same as the commercial support from component oriented companies, including the UI/UX care of some components.
- 7y ago
- de_watcher 7y agoForgot rr - reverse debugger: https://rr-project.org https://rr-project.org Also MXE - cross-compile environment: https://mxe.cc/ https://mxe.cc/
- CptMauli 7y agoAny good recommendations for logging? (Embedded environment with SD card)
- pnako 7y agospdlog is well regarded (I use it and I like it). It's configurable enough that should be able to use it in an embedded environment; you can control the flush policy and use it in either sync or async mode. You can use method calls or macros (if you want to completely removed things like DEBUG and TRACE calls in production). You can use it as either header-only or traditional library. Really it's a great library.
- ferdek 7y agoI see no mention of various implementations of C/C++ standard libraries. It's like the second most important decision to make just after compiler vendor (or THE most important, whatever your priorities are)
- gpderetta 7y agoI would say that in 99% of the cases, using the standard library of the compiler is the right decision. Also you should target multiple compilers, possibly on multiple platforms.
- Iv 7y agoI had to use Qt as the UI lib for a project, it made me discover that QtCreator was actually not a Qt-only tool but a very good lightweight and generic C++ IDE. That's my choice now. I need something that can navigate easily in a code base, I don't really like learning all the oddities around emacs and vim (even though I am a bit competent at vim) and I don't see what is so bad in using a mouse. At first I thought annoying to have to manually edit the .includes and .config to add the includes and the macro I needed in our complex, hard-to-parse CMake based project, but now I really enjoy the freedom it gives.
- Wyndtroy2012 7y agoThe matter with C++ is not the lack of tools for it, it is that there are too many and it is a disaster with things that should be integrated into the lang arent so it makes an old and obsolete ecosystem. The build system with so many options that are incompatible between then is a good example, i dont care that i can choose among 5, make, cmake, qt, Visual Studio or Conan as it is a loose-loose scenario, no matter what i choose i always loose, i use Cmake but as any should know many libs still dont have cmakelist in their project so extra work, in cases like with ffmpeg (the reference codec library of the world) it means forget the idea as creating the txt file will need hundreds of hours as i code on Windows and cant build it. The poor ecosystem that feels like the 80s is one of the reason i am using less C++ and more other langs, i hope the ISO addrees this soon beacuse it matters even if many are happy how things are today.
- tpush 7y agoThese days, I found the best IDE like experience coding C to be CMake generating the compile_commands.json and a handcrafted .clang-format. Both used as input to clangd via VSCode’s vscode-clangd plug-in. Works pretty great!
- typon 7y agoCoC + ccls + nvim is the fastest, smoothest C++ dev experience I have had yet. (I use CLion exclusively for debugging)