post modern C tooling - draft 6

Contemporary C tooling for making higher quality C, faster or more safely.

DRAFT 0 - 10/11/18, 
DRAFT 1 - 9/16/19, 7:19 PM, I'm still working on this, but it's already useful and I'd like some feedback - so I decided to share it early.
DRAFT 2 - 10/1/19, mostly additions to static analysis tools.
DRAFT 3 - 10/4/19, updates on build systems, package management, and complexity analysis. 
DRAFT 4 - 10/6/19, run time dynamic verification and instrumentation, sanitizers (asan/ubsan/etc), performance tools, static analyzers.
DRAFT 5 - C interpreter(s). 
DRAFT 6 - 11/6/19, mention TermDebug vim,  more windows debugging tools, C drawing for intro.



In 2001 or so people started using the phrase "Modern C++". So now that it's 2019, I guess we're in the post modern era? Anyway, this isn't a post about C++ code, but some of this information applies there too.


No logo, but it's used everywhere.


Welcome to the post modern era.

Some of the C++ people have pulled off one of the cleverest and sneakiest tricks ever. They required 'modern' C99 and C11 features in 'recent' C++ standards. Microsoft has famously still clung onto some 80s version of C with their compiler for the longest time. So it's been a decade of hacks for people writing portable code in C. For a while I thought we'd be stuck in the 80s with C89 forever. However, now that some C99 and C11 features are more widely available in the Microsoft compiler, we can use these features in highly portable code (but forget about C17/C18 ISO/IEC 9899:2018/C2X stuff!!). Check out the "New" Features in C talk, and the Modern C book for more details.

So, we have some pretty new language features in C with C11.  But what about tooling?

Tools and protection for our feet.

C, whilst a work horse being used in everything from toasters, trains, phones, web browsers, ... (everything basically) - is also an excellent tool for shooting yourself in the foot.

Noun

footgun (plural footguns)
  1. (informal, humorous, derogatory) Any feature whose addition to a product results in the user shooting themselves in the foot. C.

Tools like linters, test coverage checkers, static analyzers, memory checkers, documentation generators, thread checkers, continuous integration, nice error messages, ... and such help protect our feet.

How do we do continuous delivery with a language that lets us do the most low level footgunie things ever? On a dozen CPU architectures, 32 bit, 64bit, little endian, big endian, 64 bit with 32bit pointers (wat?!?), with multiple compilers, on a dozen different OS, with dozens of different versions of your dependencies?

Surely there won't be enough time to do releases, and have time left to eat my vegan shaved ice desert after lunch?



Debuggers

Give me 15 minutes, and I'll change your mind about GDB. --
https://www.youtube.com/watch?v=PorfLSr3DDI
Firstly, did you know gdb had a curses based 'GUI' which works in a terminal? It's a quite a bit easier to use than the command line text interface. It's called TUI. It's built in, and uses emacs key bindings.

But what if you are used to VIM key bindings? cgdb to the rescue.

https://cgdb.github.io/

VIM has integrated gdb debugging with TermDebug since version 8.1.

Also, there's a fairly easy to use web based front end for GDB called gdbgui
 (https://www.gdbgui.com/). For those who don't use an IDE with debugging support built in (such as Visual studio by Microsoft or XCode by Apple).





Reverse debugger

Normally a program runs forwards. But what about when you are debugging and you want to run the program backwards?

Set breakpoints and data watchpoints and quickly reverse-execute to where they were hit.

How do you tame non determinism to allow a program to run the same way it did when it crashed? In C and with threads some times it's really hard to reproduce problems.

rr helps with this. It's actual magic.

https://rr-project.org/






LLDB - the LLVM debugger.

Apart from the ever improving gdb, there is a new debugger from the LLVM people - lldb ( https://lldb.llvm.org/ ).


IDE debugging

Visual Studio by Microsoft, and XCode by Apple are the two heavy weights here.

The free Visual Studio Code also supports debugging with GDB. https://code.visualstudio.com/docs/languages/cpp

Sublime is another popular editor, and there is good GDB integration for it too in the SublimeGDB package (https://packagecontrol.io/packages/SublimeGDB).

Windows debugging

Suppose you want to do post mortem debugging? With procdump and WinDbg you can.

Launch a process and then monitor it for exceptions:
C:\>procdump -e 1 -f "" -x c:\dumps consume.exe
This makes some process dumps when it crashes, which you can then open with WinDbg(https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-using-windbg-preview).


Portable building, and package management

C doesn't have a package manager... or does it?

Ever since Debian dpkg, Redhat rpm, and Perl started doing package management in the early 90s people world wide have been able to share pieces of software more easily. Following those systems, many other systems like Ruby gems, JavaScript npm, and Pythons cheese shop came into being. Allowing many to share code easily.

But what about C? How can we define dependencies on different 'packages' or libraries and have them compile on different platforms?

How do we build with Microsofts compiler, with gcc, with clang, or Intels C compiler? How do we build on Mac, on Windows, on Ubuntu, on Arch linux? Sometimes we want to use an Integrated Development Environment (IDE) because they provide lots of nice tools. But maybe also three IDEs (XCode, Microsoft Visual C, CLion, ...) depending on platform. But we don't want to have to keep several IDE project files up to date. But we also want to integrate nicely with different OS packagers like Debian, FreeBSD. We want people to be able to use apt-get install for their dependencies if they want. We also want to cross compile code on our beefy workstations to work on microcontrollers or slower low memory systems (like earlier RaspberryPi systems).



The Meson Build System.

If CMake is modern, then The Meson Build System (https://mesonbuild.com/index.html) is post modern.
"Meson is an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.
The main design point of Meson is that every moment a developer spends writing or debugging build definitions is a second wasted. So is every second spent waiting for the build system to actually start compiling code."
It's first major user was GStreamer, a multi platform multimedia toolkit which is highly portable. Now it is especially popular in the FreeDesktop world with projects like gstreamer, GTK, and systemd amongst many others using it.

The documentation is excellent, and it's very fast compared to autotools or cmake.
https://www.youtube.com/watch?v=gHdTzdXkhRY


Example meson.build for example project polysnake (https://github.com/jpakkane/polysnake):
"A Python extension module that uses C, C++, Fortran and Rust"?
 
project('polysnake', 'c', 'cpp', 'rust', 'fortran',
  default_options : ['cpp_std=c++14'],
  license : 'GPL3+')

py3_mod = import('python3')
py3_dep = dependency('python3')

# Rust integration is not perfect.
rustlib = static_library('func', 'func.rs')

py3_mod.extension_module('polysnake',
  'polysnake.c',
  'func.cpp',
  'ffunc.f90',
  link_with : rustlib,
  dependencies : py3_dep)

IDEs are supported by exporting to XCode+Visual Studio, and they provide their own interface (which a few less well known IDEs are starting to use).


Conan package manager

There are several packaging tools for C these days, but one of the top contenders is Conan (https://conan.io/).
"Conan, the C / C++ Package Manager for Developers  The open source, decentralized and multi-platform package manager to create and share all your native binaries."
What does a CMake conan project look like? (https://github.com/conan-io/hello)
What does a conan Meson project look like? (https://docs.conan.io/en/latest/reference/build_helpers/meson.html)


CMake

"Modern CMake" is the build tool of choice for many C projects.

Just don't read the official docs, or the official book - they're quite out of date.
An Introduction to Modern CMake (https://cliutils.gitlab.io/modern-cmake/)
CGold: The Hitchhiker’s Guide to the CMake (https://cgold.readthedocs.io/en/latest/)

"CMake is a meta build system. It can generate real native build tool files from abstracted text configuration. Usually such code lives in CMakeLists.txt files."

Around 2015-2016 a bunch of IDEs got support for CMake: Microsoft Visual Studio, CLion, QtCreator, KDevelop, and Android Studio (NDK). And a lot of people tried extra hard to like it, and a lot of C projects started supporting it.

Apart from wide IDE support, it is also supported quite well by package managers like VCPkg and Conan.


Interpreter and REPL

Usually C is compiled.
Bic is an interpreter for C (https://github.com/hexagonal-sun/bic).

bic: A C interpreter and API explorer

Additionally there is "Cling" which is based on the LLVM infrastructure and can even do C++.
https://github.com/root-project/cling




Testing coverage.

Tests let us know that some certain function is running ok. Which code do we still need to test?

gcov, a tool you can use in conjunction with GCC to test code coverage in your programs.
lcov, LCOV is a graphical front-end for GCC's coverage testing tool gcov.


Instructions from codecov.io on how to use it with C, and clang or gcc. (codecov.io is free for public open source repos).
https://github.com/codecov/example-c


Here's documentation for how CPython gets coverage results for C.
 https://devguide.python.org/coverage/#measuring-coverage-of-c-code-with-gcov-and-lcov

Here is the CPython Travis CI configuration they use.
https://github.com/python/cpython/blob/master/.travis.yml#L69
    - os: linux
      language: c
      compiler: gcc
      env: OPTIONAL=true
      addons:
        apt:
          packages:
            - lcov
            - xvfb
      before_script:
        - ./configure
        - make coverage -s -j4
        # Need a venv that can parse covered code.
        - ./python -m venv venv
        - ./venv/bin/python -m pip install -U coverage
        - ./venv/bin/python -m test.pythoninfo
      script:
        # Skip tests that re-run the entire test suite.
        - xvfb-run ./venv/bin/python -m coverage run --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures
      after_script:  # Probably should be after_success once test suite updated to run under coverage.py.
        # Make the `coverage` command available to Codecov w/ a version of Python that can parse all source files.
        - source ./venv/bin/activate
        - make coverage-lcov
        - bash > (curl -s https://codecov.io/bash)




Static analysis

"Static analysis has not been helpful in finding bugs in SQLite. More bugs have been introduced into SQLite while trying to get it to compile without warnings than have been found by static analysis." -- https://www.sqlite.org/testing.html

According to David Wheeler in "How to Prevent the next Heartbleed" (https://dwheeler.com/essays/heartbleed.html#static-not-found the security problem with a logo, a website, and a marketing team) only one static analysis tool found the Heartbleed vulnerability before it was known. This tool is called CQual++. One reason for projects not using these tools is that they have been (and some still are) hard to use. The LLVM project only started using the clang static analysis tool on it's own projects recently for example. However, since Heartbleed in 2014 tools have improved in both usability and their ability to detect issues.

I think it's generally accepted that static analysis tools are incomplete, in that each tool does not guarantee detecting every problem or even always detecting the same issues all the time. Using multiple tools can therefore be said to find multiple different types of problems.


Compilers are kind of smart

The most basic of static analysis tools are compilers themselves. Over the years they have been getting more and more tools which used to only be available in dedicated Static Analyzers and Lint tools.
Variable shadowing and format-string mismatches can be detected reliably and quickly is because both gcc and clang do this detection as part of their regular compile. --  Bruce Dawson
Here we see two issues (which used to be) very common in C being detected by the two most popular C compilers themselves.

Compiling code with gcc "-Wall -Wextra -pedantic" options catches quite a number of potential or actual problems (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html). Other compilers check different things as well. So using multiple compilers with their warnings can find plenty of different types of issues for you.

Compiler warnings should be turned in errors on CI.

By getting your errors down to zero on Continuous Integration there is less chance of new warnings being introduced that are missed in code review. There are problems with distributing your code with warnings turned into errors, so that should not be done.

Some points for people implementing this:
  • -Werror can be used to turn warnings into errors
  • -Wno-error=unknown-pragmas
  • should run only in CI, and not in the build by default. See werror-is-not-your-friend (https://embeddedartistry.com/blog/2017/5/3/-werror-is-not-your-friend).
  • Use most recent gcc, and most recent clang (change two travis linux builders to do this).
  • first have to fix all the warnings (and hopefully not break something in the process).
  • consider adding extra warnings to gcc: "-Wall -Wextra -Wpedantic" See C tooling
  • Also the Microsoft compiler MSVC on Appveyor can be configured to treat warnings as errors. The /WX argument option treats all warnings as errors. See MSVC warning levels
  • For MSVC on Appveyor, /wdnnnn Suppresses the compiler warning that is specified by nnnn. For example, /wd4326 suppresses compiler warning C4326.
If you run your code on different CPU architectures, these compilers can find even more issues. For example 32bit/64bit Big Endian, and Little Endian.


Static analysis tool overview.

Static analysis can be much slower than the analysis usually provided by compilation with gcc and clang. It trades off more CPU time for (hopefully) better results.


cppcheck focuses of low false positives and can find many actual problems.
Coverity, a commercial static analyzer, free for open source developers
CppDepend, a commercial static analyzer based on Clang
codechecker, https://github.com/Ericsson/codechecker
cpplint, Cpplint is a command-line tool to check C/C++ files for style issues following Google's C++ style guide.
Awesome static analysis, a page full of static analysis tools for C/C++. https://github.com/mre/awesome-static-analysis#cc
PVS-Studio, a commercial static analyzer, free for open source developers.


The Clang Static Analyzer

The Clang Static Analyzer (http://clang-analyzer.llvm.org/) is a free to use static analyzer that is quite high quality.
The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs. Currently it can be run either as a standalone tool or within Apple Xcode. The standalone tool is invoked from the command line, and is intended to be run in tandem with a build of a codebase.
The talk "Clang Static Analysis" (https://www.youtube.com/watch?v=UcxF6CVueDM) talks about an LLVM tool called codechecker (https://github.com/Ericsson/codechecker).

On MacOS an up to date scan-build and scan-view is included with the brew install llvm.

$SCANBUILD=`ls /usr/local/Cellar/llvm/*/bin/scan-build`
$SCANBUILD -V python3 setup.py build

On Ubuntu you can install scan-view with apt-get install clang-tools.


cppcheck 

Cppcheck is an analysis tool for C/C++ code. It provides unique code analysis to detect bugs and focuses on detecting undefined behaviour and dangerous coding constructs. The goal is to detect only real errors in the code (i.e. have very few false positives).

The quote below was particularly interesting to me because it echos the sentiments of other developers, that testing will find more bugs. But here is one of the static analysis tools saying so as well.
"You will find more bugs in your software by testing your software carefully, than by using Cppcheck."
To Install cppcheck:
http://cppcheck.sourceforge.net/ and https://github.com/danmar/cppcheck
The manual can be found here: http://cppcheck.net/manual.pdf

brew install cppcheck bear
sudo apt-get install cppcheck bear

To run cppcheck on C code:
You can use bear (the build ear) tool to record a compilation database (compile_commands.json). cppcheck can then know what c files and header files you are using.

# call your build tool, like `bear make` to record. 
# See cppcheck manual for other C environments including Visual Studio.
bear python setup.py build
cppcheck --quiet --language=c --enable=all -D__x86_64__ -D__LP64__ --project=compile_commands.json

 It does seem to find some errors, and style improvements that other tools do not suggest. Note that you can control the level of issues found to errors, to portability and style issues plus more. See cppcheck --help and the manual for more details about --enable options.

For example these ones from the pygame code base:
[src_c/math.c:1134]: (style) The function 'vector_getw' is never used.
[src_c/base.c:1309]: (error) Pointer addition with NULL pointer.
[src_c/scrap_qnx.c:109]: (portability) Assigning a pointer to an integer is not portable.
[src_c/surface.c:832] -> [src_c/surface.c:819]: (warning) Either the condition '!surf' is redundant or there is possible null pointer dereference: surf.

/Analyze in Microsoft Visual Studio

Visual studio by Microsoft can do static code analysis too. ( https://docs.microsoft.com/en-us/visualstudio/code-quality/code-analysis-for-c-cpp-overview?view=vs-2017)

"Using SAL annotations to reduce code defects." (https://docs.microsoft.com/en-us/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects?view=vs-2019)
"In GNU C and C++, you can use function attributes to specify certain function properties that may help the compiler optimize calls or check code more carefully for correctness."
https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Custom static analysis for API usage

Probably one of the most useful parts of static analysis is being able to write your own checks. This allows you to do checks specific to your code base in which general checks will not work. One example of this is the gcc cpychecker (https://gcc-python-plugin.readthedocs.io/en/latest/cpychecker.html). With this, gcc can find API usage issues within CPython extensions written in C. Including reference counting bugs, and NULL pointer de-references, and other types of issues. You can write custom checkers with LLVM as well in the "Checker Developer Manual" (https://clang-analyzer.llvm.org/checker_dev_manual.html)

There is a list of GCC plugins (https://gcc.gnu.org/wiki/plugins) among them are some Linux security plugins by grsecurity.


Runtime checks and Dynamic Verification

Dynamic verification tools examine code whilst it is running. By running your code under these dynamic verification tools you can help detect bugs. Either by testing manually, or by running your automated tests under the watchful eye of these tools. Runtime dynamic verification tools can detect certain errors that static analysis tools can't.

Some of these tools are quite easy to add to a build in Continuous Integration(CI). So you can run your automated tests with some extra dynamic runtime verification enabled.

Take a look at how easy they are to use?
./configure CFLAGS="-fsanitize=address,undefined -g" LDFLAGS="-fsanitize=address,undefined"
make
make check

Address Sanitizer

Doing a test run with an address sanitizer apparently helps to detect various types of bugs.
AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library. The tool can detect the following types of bugs:
  • Out-of-bounds accesses to heap, stack and globals
  • Use-after-free
  • Use-after-return (runtime flag ASAN_OPTIONS=detect_stack_use_after_return=1)
  • Use-after-scope (clang flag -fsanitize-address-use-after-scope)
  • Double-free, invalid free
  • Memory leaks (experimental)
How to compile a python C extension with clang on MacOS:
LDFLAGS="-g -fsanitize=address" CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" python3 setup.py install



Undefined Behaviour Sanitizer

From https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior detector. UBSan modifies the program at compile-time to catch various kinds of undefined behavior during program execution, for example:
  • Using misaligned or null pointer
  • Signed integer overflow
  • Conversion to, from, or between floating-point types which would overflow the destination
You can use the Undefined Behaviour Sanitizer with clang and gcc. Here is the gcc documentation for Instrumentation Options and UBSAN (https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html).
 
From https://www.sqlite.org/testing.html
To help ensure that SQLite does not make use of undefined or implementation defined behavior, the test suites are rerun using instrumented builds that try to detect undefined behavior. For example, test suites are run using the "-ftrapv" option of GCC. And they are run again using the "-fsanitize=undefined" option on Clang. And again using the "/RTC1" option in MSVC
To compile a python C extension with a UBSAN with clang on Mac do:
LDFLAGS="-g -fsanitize=undefined" CFLAGS="-g -fsanitize=undefined -fno-omit-frame-pointer" python3 setup.py install

Microsoft Visual Studio Runtime Error Checks

The Microsoft Visual Studio compiler can use the Run Time Error Checks feature to find some issues. /RTC (Run-Time Error Checks) (https://docs.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=vs-2019)

From How to: Use Native Run-Time Checks (https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-use-native-run-time-checks?view=vs-2019)
  • Stack pointer corruption.
  • Overruns of local arrays.
  • Stack corruption.
  • Dependencies on uninitialized local variables.
  • Loss of data on an assignment to a shorter variable.

App Verifier

"Any Windows developers that are listening to this: if you’re not using App Verifier, you are making a mistake." -- Bruce Dawson
Stangely App Verifier does not have very good online documentation. The best article available online about it is: Increased Reliability Through More Crashes (https://randomascii.wordpress.com/2011/12/07/increased-reliability-through-more-crashes/)
Application Verifier (AppVerif.exe) is a dynamic verification tool for user-mode applications. This tool monitors application actions while the application runs, subjects the application to a variety of stresses and tests, and generates a report about potential errors in application execution or design.
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/application-verifier
https://docs.microsoft.com/en-us/windows/win32/win7appqual/application-verifier
https://docs.microsoft.com/en-us/security-risk-detection/concepts/application-verifier

  • Buffer over runs
  • Use after free issues
  • Thread issues including using TLS properly.
  • Low resource handling
  • Race conditions
If you have a memory corruption bug, App Verifier might be able to help you find it. If you are using Windows APIs wrong, have some threading issues, want to make sure you app runs under harsh conditions -- App Verifier might help you find it.

Related to App Verifier is the PageHeap tool(https://support.microsoft.com/en-us/help/286470/how-to-use-pageheap-exe-in-windows-xp-windows-2000-and-windows-server) It helps you find memory heap corruptions on Windows.




Performance profiling and measurement

“The objective (not always attained) in creating high-performance software is to make the software able to carry out its appointed tasks so rapidly that it responds instantaneously, as far as the user is concerned.”  Michael Abrash. “Michael Abrash’s Graphics Programming Black Book.”
Reducing energy usage, and run time requirements of apps can often be a requirement or very necessary. For a mobile or embedded application it can mean the difference of being able to run the program at all. Performance can directly be related to user happiness but also to the financial performance of a piece of software.

But how to we measure the performance of a program, and how to we know what parts of a program need improvement? Tooling can help.

Valgrind

Valgrind has its own section here because it does lots of different things for us. It's a great tool, or set of tools for improving your programs. It used to be available only on linux, but is now also available on MacOS.

Apparently Valgrind would have caught the heartbleed issue if it was used with a fuzzer.

http://valgrind.org/docs/manual/quick-start.html

Apple Performance Tools

Apple provides many performance related development tools. Along with the gcc and llvm based tools, the main tool is called Instruments. Instruments (part of Xcode) allows you to record and analyse programs for lots of different aspects of performance - including graphics, memory activity, file system, energy and other program events. By being able to record and analyse different types of events together can make it convienient to find performance issues.


LLVM performance tools.

Many of the low level parts of the tools in XCode are made open source through the LLVM project. See "LLVM Machine Code Analyzer" ( https://llvm.org/docs/CommandGuide/llvm-mca.html) as one example. See the LLVM XRay instrumentation (https://llvm.org/docs/XRayExample.html).

There's also an interesting talk on XRay here "XRay in LLVM: Function Call Tracing and Analysis" (https://www.youtube.com/watch?v=jyL-__zOGcU) by Dean Michael Berris.


GNU/Linux tools



Microsoft performance tools.


Intel performance tools.

https://software.intel.com/en-us/vtune




Caching builds

https://ccache.samba.org/

ccache is very useful for reducing the compile time of large C projects. Especially when you are doing a 'rebuild from scratch'. This is because ccache can cache the compilation of parts in this situation when the files do not change.
http://itscompiling.eu/2017/02/19/speed-cpp-compilation-compiler-cache/

This is also useful for speeding up CI builds, and especially when large parts of the code base rarely change.


Distributed building.


distcc https://github.com/distcc/distcc
icecream https://github.com/icecc/icecream


Complexity of code.

"Complex is better than complicated. It's OK to build very complex software, but you don't have to build it in a complicated way. Lizard is a free open source tool that analyse the complexity of your source code right away supporting many programming languages, without any extra setup. It also does code clone / copy-paste detection."
Lizard is a modern complexity command line tool,
that also has a website UI: http://www.lizard.ws/
https://github.com/terryyin/lizard

# install lizard
python3 -m pip install lizard
# show warnings only and include/exclude some files.
lizard src_c/ -x"src_c/_sdl2*" -w 

# Can also run it as a python module.
python3 -m lizard src_c/ -x"src_c/_sdl2*" -w

# Show a full report, not just warnings (-w).
lizard src_c/ -x"src_c/_sdl2*" -x"src_c/_*" -x"src_c/SDL_gfx*" -x"src_c/pypm.c"

Want people to understand your code? Want Static Analyzers to understand your code better? Want to be able to test your code more easily? Want your code to run faster because of less branches? Then you may want to find complicated code and refactor it.

Lizard can also make a pretty word cloud from your source.

Lizard complexity analysis can be run in Continuous Integration (CI). You can also give it lists of functions to ignore and skip if you can't refactor some function right away. Perhaps you want to stop new complex functions from entering your codebase? To stop new complex functions via CI make a supression list of all the current warnings and then make your CI use that and fail if there are new warnings.



Testing your code on different OS/architectures.

Sometimes you need to be able to fix an issue on an OS or architecture that you don't have access to. Luckily these days there are many tools available to quickly use a different system through emulation, or container technology.


Vagrant
Virtualbox
Docker
Launchpad, compile and run tests on many architectures.
Mini cloud (ppc machines for debugging)

If you pay Travis CI, they allow you to connect to the testing host with ssh when a test fails.


Code Formatting

clang-format

clang-format - rather than manually fix various formatting errors found with a linter, many projects are just using clang-format to format the code into some coding standard.



Services

LGTM is an 'automated code review tool' with github (and other code repos) support. https://lgtm.com/help/lgtm/about-automated-code-review

Coveralls provides a store for test coverage results with github (and other code repos) support. https://coveralls.io/




Coding standards for C

There are lots of coding standards for C, and there are tools to check them.


An older set of standards is the MISRA_C (https://en.wikipedia.org/wiki/MISRA_C) aims to facilitate code safety, security, and portability for embedded systems.

The Linux Kernel Coding standard (https://www.kernel.org/doc/html/v4.10/process/coding-style.html) is well known mainly because of the popularity of the Linux Kernel. But this is mainly concerned with readability.

A newer one is the CERT C coding standard (https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards), and it is a secure coding standard (not a safety one).

The website for the CERT C coding standard is quite amazing. It links to tools that can detect each of the problems automatically (when they can be). It is very well researched, and links each problem to other relevant standards, and gives issues priorities. A good video to watch on CERT C is "How Can I Enforce the SEI CERT C Coding Standard Using Static Analysis?" (https://www.youtube.com/watch?v=awY0iJOkrg4). They do releases of the website, which is edited as a wiki. At the time of writing the last release into book form was in 2016.







How are other projects tested?

We can learn a lot by how other C projects are going about their business today.
Also, thanks to CI testing tools defining things in code we can see how automated tests are run on services like Travis CI and Appveyor.

SQLite

"How SQLite Is Tested"

Curl

"Testing Curl"
https://github.com/curl/curl/blob/master/.travis.yml

Python

"How is CPython tested?"
https://github.com/python/cpython/blob/master/.travis.yml

OpenSSL

"How is OpenSSL tested?"

https://github.com/openssl/openssl/blob/master/.travis.yml
They use Coverity too: https://github.com/openssl/openssl/pull/9805
https://github.com/openssl/openssl/blob/master/fuzz/README.md

libsdl

"How is SDL tested?" [No response]

Linux

https://stackoverflow.com/questions/3177338/how-is-the-linux-kernel-testedhttps://www.linuxjournal.com/content/linux-kernel-testing-and-debugging

Haproxy

https://github.com/haproxy/haproxy/blob/master/.travis.yml



There is some discussion of Post Modern C Tooling on the "C_Programming" reddit forum.



pygame book

This article will be part of a book called "pygame 4000". A book dedicated to the joy of making software for making. Teaching collaboration, low level programming in C, high level programming in Python, GPU graphics programming with a shader language, design, music, tools, quality, and shipping(software).

It's a bit of a weird book. There's a little bit of swearing in it (consider yourself fucking warned), and all profits go towards pygame development (the library, the community, and the website).

Comments

Unknown said…
Thanks for this awesome article. It really helped me. Mainly the CMake tutorial.
To activate hulu on Sony TV, firstly navigate to the Video section on the Xcross media bar. After that, go down to the green Hulu icon. Now, you will have to choose the Hulu channel and the Download the Hulu app. And for Samsung TV, press the Home button on the remote to open the Smart Hub. Now, choose Apps and then look for Hulu using the magnifying glass. Finally, proceed with the on-screen guidelines to finish the installation process of the Hulu channel. 

You can feel free to contact our technical executives at the toll-free number +1-844-885-8900 for further information and details regarding activate Hulu 
hrroman said…
If you are stuck with your management assignment then in this case you can opt for our Marketing Assignments. we provide the best online assignment help.We also provide Market Analysis Assignment for students across the globe. for more information contact us +16692714848
ROHIT RAJWANI said…
This comment has been removed by the author.
ufabet said…
really good article! you might as well want to check ufabet . Go to the website for more information
Jatin Sethi said…
Following Seven years, a couple hundred million dollars later, the PROJECT MATCH STUDY was esteemed a horrid disappointment. Everyone and I do mean everyone, arranged to dishonor, discover shortcoming in it and fundamentally deny everything from the authenticity of the guardians of the creators to out and out misrepresentation. The reality of the situation was essentially they didn't care for the outcomes. Furthermore, the outcomes were horrid. In Patient Residential Treatment, Out Patient Alcohol and Drug Rehab
recovery quotes
rehab quotes



William Ava said…
How do I get USTVnow for free on Roku?


The USTVnow is a compatible online streaming channel and allows you to watch famous content that is aired. Moreover, this channel is now officially available on the Roku channel store; rather, you can get via your Roku account. Similarly, you can record all your favorite shows, films and watch them later.

This channel consists of three plans, the USTV Now free, USTV Now Basic, and USTV Now Basic + DVR. Make sure to subscribe to these packages before you could download the app on your Roku device. Then, you can reach the Roku sign up site and log in to your account. Under the Manage account, click the Add a channel with a code and enter the code. Once after the channel appears on the Roku screen, open it and get the activation code. You can activate it via USTVNow.com/Roku.
If you need more information about how to setup USTVNow on roku using USTVNow.com/Roku contact our technical assisitance +1-844-661-1050.
ROHIT RAJWANI said…
If you want to watch free TV shows and movies using streaming websites then there is no alternative as compared to putlocker. Also, we made a list of alternatives like Putlocker sites that you can use to stream movies and TV shows.

Here is the official Putlocker website with a lot of trending and popular movies to watch.

Hosting companies and law enforcement are always taking down free streaming sites, including long-time favorite Putlockers. So what are you supposed to do when your usual top pick for free streaming isn’t working anymore?

Don’t put away that popcorn just yet! I tested 47 leading streaming sites for safety, usability, and speed. After careful review and ranking based on streaming catalog size, content, and quality, I’ve found offical proxy site of Putlockers.
William Ava said…
Download and install Paramount Network app on Roku

Download the Paramount Network app on Roku and watch the entertaining channel programs on demand. To install the app, complete the device setup, and connect your device to the Network. After linking the device to the account, navigate to the device app store. Begin your search, typing the channel name. Collect the channel activation code and finally enter the code navigating to the page, paramountnetwork.com/activate.

For help and support to install the Paramount Network app, reach out to the network support executives by dialing the Toll free +1-805-436-1200
Roku device is the best service in the USA, Do you have an issue with your Roku Device? Get instant solution and support by Roku Helpline Number. We are dealing with a wide range of Roku streaming players and provide a complete solution for Roku devices.call +1-855-879-1273 visit here https://roku-helpnumber.com/

Roku Help Number
Roku Customer Service Number
Roku Technical Support Number
Vayu said…
Great website! To watch free movies online you can use this website! All movies updated with subtitles, no sign up required. Just search and play the movie online in HD. The one and only free movies website online: xmovies 8
mansi said…
Roku is one of the most famous live streaming TV in the United States. The organization is providing a broad array of products like Roku TV, Roku Ultra, Roku Premiere, Roku Streaming Stick, and many more. Roku products are recognized for their simplicity but sometimes users encounter Roku Activation problems and it seems very challenging for them. Today here in this post, we are going to discuss Roku Enter Com Link. Roku devices can offer its users with the best way to stream their show on TV. Nowadays, streaming players are more focused on offering the best and easy method to stream shows and programs. Also, Netflix, HotStar, Amazon Prime Video, YouTube, or any other streaming, Roku streaming device will enable you to enjoy each one of them.
Roku Enter Com Link Setup
Roku Enter Com Link is applied to activate Roku Streaming Player or Device. To enjoy all preferred channels, programs, videos, shows, and many more, users are required to activate the Roku Activation Code with a Roku Account. After buying the Roku device, you are required to create a Roku enter com link account for a streaming device with outstanding media programs or add new free or pro channels on your Roku streaming device. Roku has approx 3500+ channels and shows.
https://www.rokucomlink-account.com/
mansi said…
Roku com link provides the simplest way to stream entertainment to your TV. On your terms. With thousands of available channels to choose from and Roku is a line of digital media players manufactured by American company Roku, Inc. The devices offer access to streaming media content from various online services. The line was introduced in May 2008 with its first model, developed in collaboration with Netflix. Most Internet TV streaming devices give you some kind of search facility, but Roku has the best search function. You can quickly and easily search for movies and TV shows across Netflix, Amazon Instant Video, Hulu Plus, Crackle, VUDU, and HBO GO by title, actors, or directors. From all over the globe, you can enjoy almost more than 3000 channels on the Roku streaming device. If you are a big fan of Netflix, Roku has everything covered for you. Here some famous channels supported by Roku:
Netflix
Disney XD
HULU TV
Sling TV
ESPN+
Apple TV
Prime Video
These are just a few names to give you an idea about the storm of the entertainment. You will be amazed by the entertainment library of the Roku com link.
mansi said…
If you're unable to get Roku com link activation code then follow these steps: Go to your web ... Start your TV and device and submit your Roku Com link activation code.
Problems while using Roku
Some common problems that you might face while using Roku can be as follows:
The Internet connection can be one hurdle while using a Roku device.
In case your TV is not upgraded it will be difficult to use the Roku device. You must upgrade your TV to use the device properly.
Internet server issues can disrupt the network.
In case your network is not secure that can lead to virus attacks or system failure.
https://www.rokucomlink-account.com/
mansi said…
Activation of Roku Device
Firstly switch on the Roku TV and the streaming device.
Connect the device to your internet connection.
Launch the TV screen
Roku
com link Activation Code, once it appears on the screen after launching must be noted down.
The code consists of a URL. It is often known as Roku my account link.
Open the link in the browser to activate the Roku device.
Enter the com link activation code and login.
After login, enter the com link activation code to finally activate the Roku device.
You can also add or remove channels online using your Roku account. Roku users have to pay one time for any channel purchase. You can pay online using a credit or debit card.
Problems while using Roku
Some common problems that you might face while using Roku can be as follows:
The Internet connection can be one hurdle while using a Roku device.
In case your TV is not upgraded it will be difficult to use the Roku device. You must upgrade your TV to use the device properly.
Internet server issues can disrupt the network.
In case your network is not secure that can lead to virus attacks or system failure.
a123hp said…
How to Clean Print head of my HP Officejet pro 6968?

Start by folding the dry paper into the region and also keep the same on a plastic surface. After this, you have to open the printer and take away all the cartridges. If you find any extra ink on the nozzle, wipe them away. Then, you can place the print head in the container and the nozzle has to face below. After you clean the print head, it must be left to dry. After 10 minutes, you can reinstall the print head back to the device. In case of more issues, visit troubleshoot HP officejet pro 6968 to get an idea about troubleshooting HP officejet pro 6968.
Emily Smith said…
The blog has a few minor grammatical errors which can be corrected by the expert professionals offering affordable Assignment Help . Visit livewebtutors.com and know more about the ways the professionals can leverage your grades. Feel free to contact the professionals anytime.
go.roku.com/rss said…
Stream Comet TV on Roku
Its time to activate Comet TV on Roku and start watching the top and entertaining programs. It’s the category, Sci & Tech where you can find the channel. After adding the channel, find the activation code and you can provide the code visiting the channel activation page. Start watching the entertaining Comet TV channel programs such as The Outer Limits, Men into Space, Wild World and lot more
To get help and support to complete Comet TV activation, to know how to watch Comet TV on Roku, check out the latest article and Blog post on our portal.
Mason Lee said…
Matlab is one of the most demanded units in engineering. However many students avoid it because it is seen as a difficult topic. We are however here to ensure that you get the best Matlab Assignment Help to raise your grade as well as improving your market value. To have your Matlab assignments completed on time visit us today at matlabbassignmentexperts.com
Mason Lee said…
Hi there, I have some good news for you. Do you need Programming Homework Help? I am an online programming tutor with comprehensive programming experience in addition to a stellar academic record. Expect quality assignment solutions on programming languages such as PHP, Java, Python, C, C++ Programming, and Perl all at affordable prices. Am available on programminghomeworkhelp.com for any queries that you have.
Mason Lee said…
I am an Online
STATA Tutor
. I offer free tutoring classes in linear regression, variance, multi variance analysis, and random sampling. All my classes are meant to improve you as a statistics student as well as help you tackle your Statistics Assignment. My students are afraid of the STATA unit because their predecessors have meant them to believe that it’s a hard unit to handle. As much as it’s not that simple, I help you enjoy studying it
Lucas Miller said…
As an experienced SAS assignment solver I offer free online tutoring services. I understand that sometimes students miss classes for various reasons. One may have been sick and ended up missing a very important class or many may be combining class and work therefore work getting more attention. To ensure that you catch up with the rest of the students, I offer online classes at your convenience. My classes offer all STATA units including but not limited to survival analysis, panel data analysis, volatility modeling, and principal component analysis and factor analysis. Comment back to get in touch with me for Statistics Assignment Help.
Lucas Miller said…
I have immense knowledge in using Java for any task. I offer C Assignment Help services to students looking for Programming
Assignment Help
. My services have helped students around the world score high grades. I can help you with object-oriented programming, website development, string manipulation, and machine learning in Java.
Lucas Miller said…
Skipped your Matlab classes because of other commitments of a busy job schedule? You don’t have to worry. At Matlab assignment experts, we offer tuition classes to ensure that you catch up with your classmates or even understand the area you did not understand in class. We offer classes based on your topics of need and we work based on your schedule. Our Matlab Assignment Experts are available to ensure that your grades are soaring high.
Sophia Jones said…
I can comfortably say that I relied on Statistics Assignment Help when it comes to looking for a SPSS assignment help expert. They were very good and the grades I got were decent. However, one thing I would like to be handled is the customer care team. As much as the work is quality, communication is important. One customer care lady kept on telling me that I wait for my work instead of calling her to know how far the work was. I felt disrespected because I had paid for that service and I deserved to know the progress. Other than that communication hitch I experienced I highly rate this team for the quality of the work. I will work with them again and again.
Sophia Jones said…
Meet an experienced Programming
Homework Help
expert, with more than 10 years of industry experience and who implemented solutions using Spring, Sling, Servlets and JSPs, and most recently, Adobe Experience Manager (AEM). Also, I am an Adobe Certified Developer in AEM 6 and have been developing components in the CMS for the last 4 years. I believe in my problem solving abilities which makes me one of the experts you would prefer to provide you C Homework Help .
Roxane Fabin said…
I have a bachelor's of science in computer science and several years field experience, therefore you can expect high quality codes from me. Currently, I provide Java Homework Help in a reputable online assistance company. I will be glad to help in file handling, string manipulations, object-oriented programming concepts, exception handling and Java interfaces. Chat with me on programming homework help or email me at info@programminghomeworkhelp.com
Roxane Fabin said…
I am a statistics professor with specialization in STATA. I offer both tutoring services and assignment completion services to students looking for Statistics Homework Help . If you are looking for a STATA Assignment Help expert then look no further. All my online classes are free while the assignments are completed at a reasonable fee. All your assignments are checked for grammar and plagiarism to ensure that you deliver the best to your lecturer.
Ethan Smith said…
I took Matlab assignment helpfrom this website for my communications system assignment but the solution I got was not what I could call quality work. Of course, I can only speak from my own experience. Yes, they assigned the task to another Matlab assignment helper and the person did a good job but my question is, why not vet all the experts to find out who is really up to the task and who is not so that people can hire anyone knowing he/she will get the job done? It would save time and make things easier for everybody.
Ethan Smith said…
I am a professional java developer with years of experience in providing Programming
Homework Help
and working in a Java
Homework Help
platform. I focus on Android mobile app development, cloud development, and Java desktop or JEE projects. I am committed to producing quality java assignment solutions.
Ethan Smith said…
I have worked with so many online STATA Assignment Help tutors. But the dedication the experts at Statistics assignment help have is none like I have ever received. That makes me rank them as the best online platform that I have ever worked with. The solutions were immaculately prepared, and you cannot find any flaws.
sneha said…
During this coronavirus period, I want to learn a new skill; free lessons can be of importance. I want to learn SPSS. I need someone one experience who can guide me through the process. Maybe you will be happy to extend your SPSS Assignment Help services to me. I have heard a lot about services Statistics Homework Help
experts provide.

sneha said…
My work schedule is so tight and therefore I want a programming homework help provider who is experienced in providing C homework help who can help me complete my C programming assignments from time to time. I will be ready to give him the login details to my class so that I don’t have to check whether there are pending assignments. If there is an assignment you will just be emailing me the quotation of having the work done and then you complete it and submit it in the class portal.
Is Varanasi’s beauty seen only in its sunrises and sunsets? No. That’s why Varanasi Tours are musts. For example, you must experience a serene sunrise boat trip, an evening aarti on the Ganga and a walk through its narrow lanes.
Do you offer statistics assignment help with convolutions in the topic of probability theory? The probability theory topic in statistics keeps getting harder as we proceed further in the topic. Convolutions are one of the concepts. What I understood from my class lectures was it involved using the formula below for the discrete case. Let me know how much you would charge per hour for one on one classes. In addition I also need Econometrics assignment help experts. I have sent the details to you and therefore I am waiting for your feedback.
Looking for online Matlab Homework Help? Find reliable and efficient MatLab assignment solutions from experienced MatLab professionals at Matlab Assignment Experts. Visit our website today and boost your grades in MatLab. You can avail of our Matlab Assignment Help and score high grades.
Jack Lee said…
Do you guys give a commission if someone decides to give you clients? I have more than 20 students who are looking for Programming Homework Help. I want to act as a broker between you and them provided we agree that you are going to pay me a certain percentage of the profit. If you prove to be reliable then I will give you a huge number of students because I have access to many of them.Right now I have couple of students looking for C++ Assignment Help
Jack Lee said…
Hi there, I am a statistics student who loves the course but is highly challenged by it. I therefore need a very experienced statistics homework help expert to do my statistics assignment on SAS. If you have a good SAS assignments help expert then I am willing to pay today to have the work started.
Sadiya said…
Hi, I have sent my Java assignment to your email as instructed in your programming homework help portal. I don’t have much time online and therefore I am requesting you to check it now so that you can give me a quotation. All the details of my assignment are provided and I hope you get me a well-experienced C++ homework help tutor to work on it. Kindly note that deadlines mean everything to me and I don’t expect you to take me rounds about the delivery of the work.
benrusso62060 said…
Don’t let your image processing assignment stop you from getting an excellent grade in Matlab. Our Matlab Assignment Help team is always available to give you a helping hand in your assignments. Our prices consider the fact that you are students and therefore are friendly. The friendly prices do not mean that our quality of delivery is compromised. All our assignments are done by professionals and therefore through us, you are guaranteed top grades.
Sadiya said…
I worked with a tutor from your team last year who offered amazing econometrics assignment help. This time round I am not looking for an assignment helper but a general statistics assignment help tutor to help me prepare for my exams. I have a very busy work schedule and therefore I am available for limited hours. Kindly let me know whether you have a tutor available for a one-on-one class.
Jack Lee said…
My advice to this company is one. Please don’t say you deliver timely Matlab assignment help yet some of your writers are too lazy to keep the deadlines. I was very clear that I needed my communications system assignment done within 24 hours and the person I gave the job promised he was going to keep time. Well, guess what, the person delivered the work two days later saying he had an issue with his laptop. I still don’t know what could have happened if I hadn’t been smart enough to lie about my deadline. It saved my life because I was able to hire another Matlab assignment helper for the task and this other person actually delivered the work in just 6 hours.
Devin Ronan said…
My roommate and I hired a Matlab assignment help expert from this site for our numerical methods assignments. The solutions were delivered in a timely version and I would have said more nice things about this Matlab Assignment Experts service but I believe the expert didn’t give the tasks his all. I agree, the price was quite reasonable and the solutions did prevent us from failing so thank you.
Devin Ronan said…
I heard that Statistics assignment help offer free online classes. how can I access them? Are there any charges that the above description does not offer? I need you as my STATA assignment Help expert by providing a little help on Hypergeometric distribution. It falls under the category of probability distribution. I could benefit greatly from free online classes.
Devin Ronan said…
I want to be honest with you. I am not the type of person who easily gets annoyed at people. Three months ago I sent you an email seeking programming assignment help. My C assignment was completed on time but after a struggle with the first Java homework help expert I was assigned. I only enjoyed working with you after I demanded for a new tutor. The new person I was given was amazing. Always available when needed and a good communicator. I don’t know whether you allow people to decide who should handle their papers because if it was possible then that is what I would do for the rest of my assignments.
Sadiya said…
My control systems solution was great but unfortunately, it was delivered a day after the deadline. I took Matlab assignment help from here because I had read some really good reviews about MatlabAssignmentExperts and especially where the customers were happy about their assignments being delivered on time and sometimes even a few days before the deadline. I had a totally different experience and the only reason I was able to beat my deadline was that I had given the Matlab assignment helperwho handled my task the wrong deadline. Still, the platform isn’t so bad because I got a decent grade from the solution they prepared but they should address the late delivery issue asap.
Lucas Miller said…
If an assignment is completed and there is a need for revision do you charge or is the revision free. I would like to know your economics assignment help terms before hiring you so that we can be on the same page. There are economics homework help platforms that charge for revision yet it’s their mistake. If your revision is free and your charges are fair, then I would be happy to work with you.
Lucas Miller said…
Skipped your Matlab classes because of other commitments of a busy job schedule? You don’t have to worry. At Matlab Assignment Help we offer tuition to ensure that you catch up with your classmates or even understand the area you did not understand in class. We offer classes based on your topics of need and we work based on your schedule. Our Matlab Homework Help team is available to ensure that your grades are soaring high.
Lucas Miller said…
In my statistics class, we are at the point where we are discussing the log-rank tests. That is the topic of survival analysis. I started well on the topic and understood the Kaplan-Meier test but had a problem with understanding the log-rank test. Perhaps as an experienced statistics homework help expert, you could help me with it. I am adding another assignment to it on SAS. The SAS one is not very urgent because it is due in one month, however, it is quite complex and therefore I will need a highly experienced SAS assignment help expert.
Lucas Miller said…
Have you centralized your work? I want a programming assignment help expert from Canada. If you have one from this side of the world, I am going to take your C++ assignment help today to have my C++ assignment completed. I do not have much time to do it and that is why I am seeking professional assistance in order to have high grades. Let me know whether you have one. If none then you can let me know whether there is one from a country close to Canada.
Frank Miller said…
Sometimes I feel like the prices these guys charge for Matlab assignment help is too high compared to other sites. But don’t get me wrong, their Matlab assignment helpers are great at what they do. They actually helped me score an A in my control systems assignments. I just feel they should try bring the prices down a little bit.
Frank Miller said…
I have had so many disappointments online. I have found it so hard to trust anyone online. I am giving it a last go with you. I want economics assignment help which must be delivered in 48 hours. If it is not possible just be frank and say it is not. More to that I would like to see your economics homework help samples to ascertain that I am hiring the right person. I just hope I won’t be disappointed this time around.
Frank Miller said…
Which is the best software for statistics homework help? There is so much software that can be used for statistics. But I can't learn how to use all of them. I desire to be a master in statistical software that is considered the best. Which software should I learn for doing my statistics homework? More to that, where can I get SAS assignment help?
Frank Miller said…
After having three amazing years of taking programming assignment help from you, last week I had a bad experience when I came to you for C++ assignment help. I was given a different tutor from the ones I have been working with. I assumed all would be well since in the past all tutors I got had proved to be amazing. This new tutor was very poor in communication and in most cases he was even not available. Within 3 days I was already tired of him because he was not even sending work progress. I simply had to launch a complaint with the customer care team. After I launched the complaint it’s when he rushed to my inbox to tell me that my work was in progress. I refused to work with him and requested for a new tutor.
Roxane Fabin said…
How do I know that you are offering the best economics assignment help? I have worked with more platforms in the past and I have had a lot of disappointments. I would be happy if you offered me economics homework help samples so that I can see the quality of work I should expect from you. If you satisfy me in the first task, then I am going to hire you for more work.

Popular posts from this blog

Is PostgreSQL good enough?

Pixel perfect collision detection in pygame with masks.