7 ms·
Additional C/C++ Tooling
- mden 11y agoOur team has had a decent compile time improvement by switching to ninja[1] from gmake. [1] https://martine.github.io/ninja/manual.html https://martine.github.io/ninja/manual.html
- vezzy-fnord 11y agoNo build system thus far reaches the elegance of redo, though.
- Joky 11y agoMy experience has been very positive for incremental build (you have built once a large software and change one file and need to rebuild) but no difference on fresh build.
- mahyarm 11y agoAfter a certain point, you can't get over compiler processing time.
- mden 11y agoNinja's magic happens before the compiler in deciding what needs to be compiled quicker than gmake.
- mahyarm 11y agoThat's what I meant. If you have to rebuild everything, then ninja or gmake doesn't make anything faster, since it's the compiler's speed at that point.
- Joky 11y agoWell there is still the amount of parallelism that can be exposed. It just seems that CMake exposes it as well for make than for ninja I guess.
- mden 11y agoYup exactly what we use it for. Combined with Jenkins, makes it easy to make sure your master branch is in a good state.
- dima55 11y agoIf you mean as a backend to CMake, then it's entirely the fault of CMake's braindead-ness
- mden 11y agoExplain. You are saying CMake is bad with gmake but good with ninja?
- amelius 11y ago> What did I miss? Perhaps a tool to generate header files, so we don't have to write every function declaration twice?
- MichaelCrawford 11y agoI design my programs by writing the header files first.
- huu 11y agoThis approach makes me happy. Interface is key.
- nulltype 11y agoI use makeheaders: http://www.hwaci.com/sw/mkhdr/ http://www.hwaci.com/sw/mkhdr/ 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 http://doc.cat-v.org/bell_labs/pikestyle
- ndesaulniers 11y agoSuch as? Take my money!
- MichaelCrawford 11y agoThe term "C/C++" is a Tool of the Devil. Each has its many endearing qualities but it is inappropriate to put them together like that. 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.
- glandium 11y agoThe OP is about tools to build, develop and debug C and C++. None of the mentioned tools apply to one and not the other. Why would you want the title not to mention both?
- ndesaulniers 11y agoI agree, C and C++ despite many similarities and close ties in their family trees are quite different. I did not make that point in the article, as it's irrelevant to a piece on tooling that works for both.
- TwoBit 11y agoYou can use a C++ compiler to do "C with objects" fine. Lots of people successfully do that. There's specification for doing this in fact which is adhered to by embedded developers. It's better to use C++ more fully, of course.
- jasode 11y ago>The term "C/C++" is a Tool of the Devil. Each has its many endearing qualities but it is inappropriate to put them together like that. 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.
- banachtarski 11y agoDeath to cmake. Long live premake (5)
- ndesaulniers 11y agoTell me more.
- e12e 11y agoApparently that's a build tool that uses lua rather than some bastardized config language (like CMake does), and otherwise is somewhat inspired by CMake?: https://github.com/premake/premake-core/wiki/What_Is_Premake https://github.com/premake/premake-core/wiki/What_Is_Premake https://github.com/premake/premake-core 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 https://github.com/jimon/premake-ninja
- endgame 11y agoDeath to cmake. Long live automake.
- jschwartzi 11y agoDeath to cmake. Long live make.
- banachtarski 11y agoYou're kidding me. Have you tried to manage a cross platform build using make?
- copperx 11y agotup looks even better.
- apaprocki 11y agoIf you work at a company that can afford Coverity (static analyzer), it is great. Super simple to integrate into a standard gcc build.
- TwoBit 11y agoI'd love to see a comparison of Coverity vs. Clang sanitizers. I wish we could buy just a couple Coverity licenses, but they want to license the entire organization for something like $200,000.
- jschwartzi 11y agoJust out of curiosity, how big is your org? I've been tempted to suggest Coverity a few times but I always balk at buying tools where the price is listed as $CallSalesAndNegotiate.
- slacka 11y agoWhen Daniel Hax ran Coverity and Clang against the curl source code, he found that the each "tool detected several issues the other didn’t spot." 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-analyzers-compared/ http://daniel.haxx.se/blog/2012/07/12/three-static-code-anal... [2] http://www.viva64.com/en/b/0272/ http://www.viva64.com/en/b/0272/ [3] http://www.viva64.com/en/a/0076/ http://www.viva64.com/en/a/0076/
- exDM69 11y agoI have not tried this yet, but Coverity provides a free online tool for open source projects. It will be a nice complement to travis/coveralls and other CI tools available for free to open source projects. I'll definitely try it out once I get some time to work on infrastructure things on my own open source projects. https://scan.coverity.com/ https://scan.coverity.com/
- plorkyeran 11y agoNote that valgrind trunk now supports OS X 10.10 and 10.11 and it's completely trivial to build.
- ndesaulniers 11y agoRight, should have tried that! I bent over backwards building some of the other tools from source! See also: https://www.reddit.com/r/programming/comments/3egclc/additional_cc_tooling/ctf4565 https://www.reddit.com/r/programming/comments/3egclc/additio...
- Omnus 11y agoPeople often take it as common knowledge that Visual Studio barely supports C. As of VS2015 almost all of the C99 standard is implemented, with a few corners missing, like tgmath. I am interested to see if this allows more C libraries to be built with VS rather than relying on MinGW and other Unix based alternatives.
- ndesaulniers 11y agoIndeed, on my post about "Designated Initialization With Compound Literals in C" [0], someone commented "cool, but I use MSVC so..." [1]. Note: that was two years ago, I'm sure that's not the case. 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-initialization-with-pointers-in-c/ http://nickdesaulniers.github.io/blog/2013/07/25/designated-... [1] http://nickdesaulniers.github.io/blog/2013/07/25/designated-initialization-with-pointers-in-c/#comment-977161427 http://nickdesaulniers.github.io/blog/2013/07/25/designated-...
- santaclaus 11y agoDoesn't Visual Studio support Clang as an official alternative to MS' compilers, now?
- ndesaulniers 11y agoIf not now, when? I suspect this is a goal of Google's.
- TwoBit 11y agoI think the answer is yes and no. You can get clang to compile standard C/C++, but not any Windows code, as Microsoft has many compiler extensions and quirks they depend on.
- pjmlp 11y agoMostly because that is required by the C++11/14 standard revisions.
- aninteger 11y ago
- angry_octet 11y agoYou lost me when you suggested cmake as a build tool. Its principal killer feature seems to be that it abstracts cross platform building. Unfortunately the price you pay for that is eventual insanity, an unreasoning desire to DESTROY EVERYTHING. Stay away from cmake.
- ndesaulniers 11y agoI will pray for your soul. :P
- TwoBit 11y agoThe thing I hate about CMake is that it can't generate relative directory structure projects. That's stupid and no other build system of significance has this limitation.
- fit2rule 11y agoI don't know what you mean - can you explain this further? Because I've seen it do what I think you mean, but I guess I don't understand.
- halosghost 11y agoI have to agree honestly. I've tried many of the build systems out there, and I have settled on tup[1] as being one of the greatest creations ever. The Tupfiles are incredibly simple, the execution time is bloody fast, and it is more capable of creating easily-reproducible builds than anything else I've seen so far. I'd recommend you give it a look if you're not familiar with it. [1] http://gittup.org/tup/ http://gittup.org/tup/
- slavik81 11y agoHaving spent moderate to significant time with bjam, waf, qmake, make and cmake, I more or less settled on cmake because: 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.
- andrewchambers 11y agoSomeone should make a cargo clone for building C/C++ code. I don't care if it makes everything statically linked, that is good for me. :)
- ndesaulniers 11y agoI was playing around with this idea [0], much to the dismay of colleagues, until I discovered that CMake's ExternalProject module could do everything my "package manager" could do. I was pretty close to making the package manager self hosting, too... 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. [0] https://github.com/nickdesaulniers/picodeps https://github.com/nickdesaulniers/picodeps
- danieldk 11y agoApparently, biicode is just exactly that. I only played around a little with the examples. So far, so good.
- nnethercote 11y agoCalling Valgrind a "memory leak detector" totally underplays its usefulness. But for some reason I've never worked out, a lot of people think this is all it does. 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.
- glandium 11y agoAnd then there are the valgrind tools other than memcheck: cachegrind (cache and branch-prediction profiler), callgrind (call-graph profiler), helgrind (thread error detector), massif (heap profiler), and probably more I forget.
- TazeTSchnitzel 11y agoSome projects use custom allocators which detect memory leaks, so it's even less useful there.
- antirez 11y agoWhile simple, osx "leaks" is truly formidable because you can call it while a program that was compiled without any special flag is running. For example the Redis testing framework runs "leaks" every time an unit was executed completely, warning the user if a leak is found. When this happens I resort to valgrind to find the cause, but to call "leaks" every time you want during development and having it running in a few seconds is a killer feature. I miss it when I develop using Linux.
- enedil 11y agoHere you are: http://www.opensource.apple.com/source/SecurityTool/SecurityTool-7/leaks.c http://www.opensource.apple.com/source/SecurityTool/Security... http://www.opensource.apple.com/source/SecurityTool/SecurityTool-55109.1/leaks.h http://www.opensource.apple.com/source/SecurityTool/Security... After reading the source, I think that you must put the binary in `/usr/bin/leaks`.
- je42 11y agoGradle also supports C/C++
- ilurk 11y agoAre there any comparisons of: 1) bazel VS. gradle 2) cmake+ninja VS. tup VS. redo
- toolslive 11y agogetting your code pass valgrind's exam is pretty essential. The only problem I have with it is that it doesn't support all syscalls.