Additional C/C++ Tooling
nickdesaulniers.github.io
nickdesaulniers.github.io
The main things that Memcheck, the default Valgrind tool, do are:
1. Detect accesses to inaccessible memory.
2. Detect dangerous uses of undefined values.
3. Detect memory leaks.
Memory leaks are arguably the least interesting of these three things.
ASAN can do 1 and 3, but cannot do 2. That's why Mozilla runs both Valgrind and ASAN on Firefox test automation.
There's a tool related to ASAN called MSAN that attempts to do 2, but 2 is really hard to do with static instrumentation so MSAN doesn't get much real-world use.
After reading the source, I think that you must put the binary in `/usr/bin/leaks`.
I wish we could buy just a couple Coverity licenses, but they want to license the entire organization for something like $200,000.
Coverity – very accurate reports and few false positives
clang-analyzer – awesome reports, missed slightly too many issues and reported slightly too many false positives [1]
You'll find similar results in PVS Studio vs clang[2] and PVS Studio vs Coverity.[3] If code quality is important to your organization, than one tool is probably not enough. If it's vital, you may want to consider another language such as Haskell or OCaml.
[1] http://daniel.haxx.se/blog/2012/07/12/three-static-code-anal...
I'll definitely try it out once I get some time to work on infrastructure things on my own open source projects.
Stay away from cmake.
A. It's what everyone else is using.
B. It's simple to do common things.
C. It's pretty darn fast with the Ninja backend.
The only downside seems to be that the cmake language is ugly and limited. Fortunately, I only need to write a tiny amount of cmake code to build most of my projects, since find_package is so good. (Though, it probably sucks to be the guys making that work.)
To be honest, every tool I've tried has kind of sucked. cmake just sucks the least. One day I'd like to investigate tup and shake, though.
cmake has won.
The other build tools tried (scons, premake, autotools) and they failed.
You don't like the syntax? Cry me a river.
It does the job. None of the other ones do.
Pragmatism > idealism. I don't care how pretty your build files are, if they don't actually work.
/shrug.
The best feature of CMake for me has been easy cross compiling so I can develop and remote debug Windows apps on my Linux box.
The end result was a love/hate relationship with cmake.
Clearly, the weakness is its hokey scripting language. The shame is that if they'd just started with something halfway reasonable like lua it would have been easier to build the tool and it would be far more powerful. Instead, they couldn't resist writing their own DSL where everything you need to do is possible but just barely. I've done so many zany hacks over the years to force it to do what I needed.
Granted, I did the major porting work to cmake 2.4. The newer versions are certainly better (no more duplicating the expression in IF()/ELSE()/ENDIF() statements!) but it's still pretty painful to write something non-trivial compared to any modern scripting language.
However, the results of cmake are fantastic. Once you've got your CMakeLists.txt's working you can largely forget about it -- it'll just work, completely cross platform. If you need to target both UNIX compilers and the Visual Studio world it's probably the best solution.
I'm sure IDE's have great features; I wanted to avoid them in the article; they are simply not for me.
[0] http://nickdesaulniers.github.io/blog/2013/07/25/designated-... [1] http://nickdesaulniers.github.io/blog/2013/07/25/designated-...
Perhaps a tool to generate header files, so we don't have to write every function declaration twice?
It's pretty amazing.
If you can't use makeheaders, I prefer the Plan 9 include style where header files are not allowed to include header files: http://doc.cat-v.org/bell_labs/pikestyle
Although it is much less practical in C++ than in plain C, when you have to put the whole class definitions (including private member functions) in a header.
A good editor/tags system/ide should support jumping between definition and declaration quickly, this definitely makes it a bit less painful (e.g. vim + ctags + cscope work fine).
I think it doesn't actually matter if dependencies are statically linked or dynamically linked, just as long as they are not installed globally, and shared between non homogenous processes.
I only played around a little with the examples. So far, so good.
See also: https://www.reddit.com/r/programming/comments/3egclc/additio...
https://github.com/premake/premake-core/wiki/What_Is_Premake
https://github.com/premake/premake-core
There are apparently some alpha-level work for supporting ninja as a backend: https://github.com/jimon/premake-ninja
1) bazel VS. gradle
2) cmake+ninja VS. tup VS. redo
I often see job board posts and get mail from recruiters seeking coders with experience in "C/C++". Consider that Linus Torvalds and Richard Stallman would be unqualified for C++ work. I myself have done so much C++ that I am not particularly good at C anymore.
If you use C++ as "A Better C" or "C With Objects" you will never get the bugs out of your code. C++ wants to be written a certain way which is quite alien to most C practices.
I do understand the common complaint about that but in the author's type of article, it's fine to lump them together. He's talking about "tools" for runtime analysis, formatters, etc. The tools he's talking about handle both languages.
His current url for the article is:
.../blog/2015/07/23/additional-c-slash-c-plus-plus-tooling/
What would be a solution to satisfy purists and always separate C from C++? Should the author create 2 separate urls?
C tooling url would be:
.../blog/2015/07/23/additional-c-tooling/
C++ tooling url would be:
.../blog/2015/07/23/additional-c-plus-plus-tooling/
And both webpages would be 99% the same and running a diff only shows that string "C language" is replaced with "C++ language". Instead of that convoluted redundancy, it's quite reasonable in this specific type of article to lump "C/C++" together.
- Development Environments
High-Level C++ is rather verbose so it is often developed in connection with an IDE, e.g. to jump to a class definition. C works way better with established tools like grep and co, as it does not do function overloading.
- Debugging
C++ is for me the most hard language to debug, as their is so much stuff you have to keep in your head. Due to name-wrangling symbols get also weird names in debuggin areas.
- FFI
C is the established high-quality FFI approach and popular languages have very good _C_ FFI support: Python, Haskell, etc. In particular it is simpler for language designers to support C.
It is similar to the Java/JavaScript debate, where one might argue that both are interpreted languages.
Yes but that's not relevant in this thread. Please try to follow the limited context of this discussion. We are not talking about the set of ALL tools of which some might be specific for C and others might be specific to C++.
Instead, we were discussing Nick Desaulniers' specific article and the particular tools he's describing in his article.