Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0e333599 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Merge branch '117_fast_mr_link' into 'master'

#117 Remove a striked through link.

Closes #117

See merge request !73
parents 71cc4bd7 95b72eb4
No related branches found
No related tags found
1 merge request!73#117 Remove a striked through link.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# [Getting started in C++](./) - [C++ in a real environment](./0-main.ipynb) - [External tools](./6-Tools.ipynb) # [Getting started in C++](./) - [C++ in a real environment](./0-main.ipynb) - [External tools](./6-Tools.ipynb)
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<h1>Table of contents<span class="tocSkip"></span></h1> <h1>Table of contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Introduction" data-toc-modified-id="Introduction-1">Introduction</a></span></li><li><span><a href="#Online-compilers" data-toc-modified-id="Online-compilers-2">Online compilers</a></span></li><li><span><a href="#Static-analyzer-tools" data-toc-modified-id="Static-analyzer-tools-3">Static analyzer tools</a></span></li><li><span><a href="#Valgrind" data-toc-modified-id="Valgrind-4">Valgrind</a></span></li><li><span><a href="#Address-sanitizer" data-toc-modified-id="Address-sanitizer-5">Address sanitizer</a></span></li><li><span><a href="#Sonarqube" data-toc-modified-id="Sonarqube-6">Sonarqube</a></span></li><li><span><a href="#Tests" data-toc-modified-id="Tests-7">Tests</a></span><ul class="toc-item"><li><span><a href="#Google-test" data-toc-modified-id="Google-test-7.1">Google test</a></span></li><li><span><a href="#Doctest" data-toc-modified-id="Doctest-7.2">Doctest</a></span></li><li><span><a href="#BoostTest" data-toc-modified-id="BoostTest-7.3">BoostTest</a></span></li><li><span><a href="#Catch2" data-toc-modified-id="Catch2-7.4">Catch2</a></span></li></ul></li><li><span><a href="#Build-system" data-toc-modified-id="Build-system-8">Build system</a></span></li><li><span><a href="#Code-formatters" data-toc-modified-id="Code-formatters-9">Code formatters</a></span></li><li><span><a href="#Doxygen" data-toc-modified-id="Doxygen-10">Doxygen</a></span></li><li><span><a href="#More..." data-toc-modified-id="More...-11">More...</a></span></li></ul></div> <div class="toc"><ul class="toc-item"><li><span><a href="#Introduction" data-toc-modified-id="Introduction-1">Introduction</a></span></li><li><span><a href="#Online-compilers" data-toc-modified-id="Online-compilers-2">Online compilers</a></span></li><li><span><a href="#Static-analyzer-tools" data-toc-modified-id="Static-analyzer-tools-3">Static analyzer tools</a></span></li><li><span><a href="#Valgrind" data-toc-modified-id="Valgrind-4">Valgrind</a></span></li><li><span><a href="#Address-sanitizer" data-toc-modified-id="Address-sanitizer-5">Address sanitizer</a></span></li><li><span><a href="#Sonarqube" data-toc-modified-id="Sonarqube-6">Sonarqube</a></span></li><li><span><a href="#Tests" data-toc-modified-id="Tests-7">Tests</a></span><ul class="toc-item"><li><span><a href="#Google-test" data-toc-modified-id="Google-test-7.1">Google test</a></span></li><li><span><a href="#Doctest" data-toc-modified-id="Doctest-7.2">Doctest</a></span></li><li><span><a href="#BoostTest" data-toc-modified-id="BoostTest-7.3">BoostTest</a></span></li><li><span><a href="#Catch2" data-toc-modified-id="Catch2-7.4">Catch2</a></span></li></ul></li><li><span><a href="#Build-system" data-toc-modified-id="Build-system-8">Build system</a></span></li><li><span><a href="#Code-formatters" data-toc-modified-id="Code-formatters-9">Code formatters</a></span></li><li><span><a href="#Doxygen" data-toc-modified-id="Doxygen-10">Doxygen</a></span></li><li><span><a href="#More..." data-toc-modified-id="More...-11">More...</a></span></li></ul></div>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Introduction ## Introduction
The purpose of this notebook is just to namedrop briefly some facilities related to C++ that might be useful. The purpose of this notebook is just to namedrop briefly some facilities related to C++ that might be useful.
It's far from exhaustive - I won't present debuggers as usually they are provided directly with your IDE (and if you're a Vim or Emacs user you probably already familiar with [gdb](https://www.gnu.org/software/gdb/)). It's far from exhaustive - I won't present debuggers as usually they are provided directly with your IDE (and if you're a Vim or Emacs user you probably already familiar with [gdb](https://www.gnu.org/software/gdb/)).
Some tools are redundant, but they are complementary: the more you may be able to use the better. The constraint is time: it is not straightforward to use some of those, and even for the user-friendly ones there is a non neglictible set-up time. But for projects that are gaining traction it becomes a no-brainer at some point to set-up those properly once and for all - usually part of [continuous integration](https://gitlab.inria.fr/FormationIntegrationContinue/gitlabciintroduction) process. Some tools are redundant, but they are complementary: the more you may be able to use the better. The constraint is time: it is not straightforward to use some of those, and even for the user-friendly ones there is a non neglictible set-up time. But for projects that are gaining traction it becomes a no-brainer at some point to set-up those properly once and for all - usually part of [continuous integration](https://gitlab.inria.fr/FormationIntegrationContinue/gitlabciintroduction) process.
## Online compilers ## Online compilers
This ~~[blog post](https://arne-mertz.de/2017/05/online-compilers/)~~ [GitHub page](https://arnemertz.github.io/online-compilers/) gives a list of online compilers we mentioned several times in this tutorial. This [GitHub page](https://arnemertz.github.io/online-compilers/) gives a list of online compilers we mentioned several times in this tutorial.
I have used only [Coliru](http://coliru.stacked-crooked.com/) which provides an API to incorporate directly some interactive code in a Web page (disclaimer - I have not used that feature yet) and [Wandbox](http://melpon.org/wandbox) which may be useful in day-to-day work as you may try a snippet of code with many configurations. It's useful for instance when you intend to use a bleeding-edge feature to see which version of compilers support it or not. There are more advanced options as [Compiler Explorer](https://godbolt.org/) which allows to explore the intermediate Assembly code generated, this is a very advanced utility that may be useful to optimize your code and to understand how a compiler internally works. I have used only [Coliru](http://coliru.stacked-crooked.com/) which provides an API to incorporate directly some interactive code in a Web page (disclaimer - I have not used that feature yet) and [Wandbox](http://melpon.org/wandbox) which may be useful in day-to-day work as you may try a snippet of code with many configurations. It's useful for instance when you intend to use a bleeding-edge feature to see which version of compilers support it or not. There are more advanced options as [Compiler Explorer](https://godbolt.org/) which allows to explore the intermediate Assembly code generated, this is a very advanced utility that may be useful to optimize your code and to understand how a compiler internally works.
## Static analyzer tools ## Static analyzer tools
[cppcheck](http://cppcheck.sourceforge.net/) is a static analyser program; it might really help you to find some questionable constructs in your code. As many tools, it's not 100 % accurate and sometimes it may raise false positives, but I nonetheless recommend it warmly. [cppcheck](http://cppcheck.sourceforge.net/) is a static analyser program; it might really help you to find some questionable constructs in your code. As many tools, it's not 100 % accurate and sometimes it may raise false positives, but I nonetheless recommend it warmly.
[cpplint](https://github.com/cpplint/cpplint) is also worth a look, we mentioned it for instance in [this chapter](./2-FileStructure.ipynb) to track down missing includes in files. [cpplint](https://github.com/cpplint/cpplint) is also worth a look, we mentioned it for instance in [this chapter](./2-FileStructure.ipynb) to track down missing includes in files.
[clang-tidy](https://clang.llvm.org/extra/clang-tidy/) is also used by some of us. [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) also includes advanced utilities to automatically refactor/correct/improve code. See the following [link](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/-/wikis/How-to-use-Clang-Tidy-to-automatically-correct-code). [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) is also used by some of us. [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) also includes advanced utilities to automatically refactor/correct/improve code. See the following [link](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/-/wikis/How-to-use-Clang-Tidy-to-automatically-correct-code).
## Valgrind ## Valgrind
[Valgrind](valgrind.org/) is mostly known as a leak checker, but is really a jack-of-all-trade tool; callgrind for instance may be used to profile your code and see where most of the computation time is spent. Some lesser-known tools are also incredibly useful: [Verrou](https://github.com/edf-hpc/verrou) for instance, developed at EDF, is a floating-point checker which helps you figure out if at some point some of your computations might be skewed by the way the computer approximates the real numbers. [Valgrind](valgrind.org/) is mostly known as a leak checker, but is really a jack-of-all-trade tool; callgrind for instance may be used to profile your code and see where most of the computation time is spent. Some lesser-known tools are also incredibly useful: [Verrou](https://github.com/edf-hpc/verrou) for instance, developed at EDF, is a floating-point checker which helps you figure out if at some point some of your computations might be skewed by the way the computer approximates the real numbers.
Unfortunately, macOS support is scarse: sometimes they plainly say it is not up-to-date, but even when they say it works the outputs were never satisfactory for me (always check `valgrind ls` first as they recommend on their website...). So even if I develop mostly in macOS I always fire up valgrind in a Linux environment. Unfortunately, macOS support is scarse: sometimes they plainly say it is not up-to-date, but even when they say it works the outputs were never satisfactory for me (always check `valgrind ls` first as they recommend on their website...). So even if I develop mostly in macOS I always fire up valgrind in a Linux environment.
## Address sanitizer ## Address sanitizer
A [recent competitor](https://github.com/google/sanitizers/wiki/AddressSanitizer) (once again use both if possible!) to Valgrind, which has the advantage of running with a much better runtime (Valgrind slows down your program tremendously). Might be integrated in some IDEs (it is in XCode on macOS). A [recent competitor](https://github.com/google/sanitizers/wiki/AddressSanitizer) (once again use both if possible!) to Valgrind, which has the advantage of running with a much better runtime (Valgrind slows down your program tremendously). Might be integrated in some IDEs (it is in XCode on macOS).
## Sonarqube ## Sonarqube
[Sonarqube](https://www.sonarqube.org/) is a development platform which inspects your code and helps to figure out where there are issues. It enables integration of multiple tools such as cppcheck mentioned earlier. If you're Inria staff, an instance was set by our [Bordeaux colleagues](http://sed.bordeaux.inria.fr/) and is [available](https://sonarqube.inria.fr/) for you. [Sonarqube](https://www.sonarqube.org/) is a development platform which inspects your code and helps to figure out where there are issues. It enables integration of multiple tools such as cppcheck mentioned earlier. If you're Inria staff, an instance was set by our [Bordeaux colleagues](http://sed.bordeaux.inria.fr/) and is [available](https://sonarqube.inria.fr/) for you.
For open-source projects, the company behind Sonarqube provides a [freely accessible platform]( https://sonarcloud.io/about). For open-source projects, the company behind Sonarqube provides a [freely accessible platform]( https://sonarcloud.io/about).
## Tests ## Tests
These are frameworks to write your tests; to actually run them you should see what your build system provides (for instance CMake comes with CTest which takes gracefully the management of tests in your project). These are frameworks to write your tests; to actually run them you should see what your build system provides (for instance CMake comes with CTest which takes gracefully the management of tests in your project).
### Google test ### Google test
[GoogleTest](https://google.github.io/googletest/) includes everything that is needed for testing: [xUnit](https://en.wikipedia.org/wiki/XUnit), test discovery, rich test assertions, death tests, XML test report generation, ... [GoogleTest](https://google.github.io/googletest/) includes everything that is needed for testing: [xUnit](https://en.wikipedia.org/wiki/XUnit), test discovery, rich test assertions, death tests, XML test report generation, ...
It is also the only one we know that provide mocks. It is worth saying that mocking in C++ requires your application to be specially designed for it, more information are available on the [gMock cookbook](https://google.github.io/googletest/gmock_cook_book.html). It is also the only one we know that provide mocks. It is worth saying that mocking in C++ requires your application to be specially designed for it, more information are available on the [gMock cookbook](https://google.github.io/googletest/gmock_cook_book.html).
### Doctest ### Doctest
[doctest](https://github.com/onqtam/doctest) is another C++ testing framework that was very appreciated by one of the teacher (Vicente) in the 2021 session of this tutorial. [doctest](https://github.com/onqtam/doctest) is another C++ testing framework that was very appreciated by one of the teacher (Vicente) in the 2021 session of this tutorial.
### BoostTest ### BoostTest
[Boost test](https://www.boost.org/doc/libs/1_69_0/libs/test/doc/html/index.html) is a widely used facility to write unit and integration tests with your code. [Boost test](https://www.boost.org/doc/libs/1_69_0/libs/test/doc/html/index.html) is a widely used facility to write unit and integration tests with your code.
It might be used as a header-only or as a compiled library; for big projects they recommend using the latter. It might be used as a header-only or as a compiled library; for big projects they recommend using the latter.
### Catch2 ### Catch2
[Catch2](https://github.com/catchorg/Catch2) is a more recent test facility which is aimed at being user-friendly. [Catch2](https://github.com/catchorg/Catch2) is a more recent test facility which is aimed at being user-friendly.
## Build system ## Build system
Already mentioned [here](./1-SetUpEnvironment.ipynb#Build-system). Already mentioned [here](./1-SetUpEnvironment.ipynb#Build-system).
## Code formatters ## Code formatters
It is useful to delegate the check on your code format to an external tool, which may take a bit of time to configurate to suit your needs. It is useful to delegate the check on your code format to an external tool, which may take a bit of time to configurate to suit your needs.
I can mention [Uncrustify](http://uncrustify.sourceforge.net/): plenty of options to configure, even if they're not easy to figure out. I can mention [Uncrustify](http://uncrustify.sourceforge.net/): plenty of options to configure, even if they're not easy to figure out.
[clang-format](https://clang.llvm.org/docs/ClangFormat.html) probably provides a better trade-off power/complexity but requires LLVM clang to be installed on your system (AppleClang won't do, but you can easily install it on macOS with Homebrew). [clang-format](https://clang.llvm.org/docs/ClangFormat.html) probably provides a better trade-off power/complexity but requires LLVM clang to be installed on your system (AppleClang won't do, but you can easily install it on macOS with Homebrew).
## Doxygen ## Doxygen
[Doxygen](http://www.doxygen.nl/) is a software to write an automatic documentation for your functions / classes / types / you name it. [Doxygen](http://www.doxygen.nl/) is a software to write an automatic documentation for your functions / classes / types / you name it.
It is rather easy to set up to easy task but may become a tad more difficult once you want to tackle more advanced features. Nonetheless it is the de-facto standard for C++ documentation and it's really something you should set up quite early if you're working on a project meant to stay for a while: it's really a hassle to spend countless hours providing after the fact such guidance in the code. As for compilers, you should strive to provide a documentation without any warning. It is rather easy to set up to easy task but may become a tad more difficult once you want to tackle more advanced features. Nonetheless it is the de-facto standard for C++ documentation and it's really something you should set up quite early if you're working on a project meant to stay for a while: it's really a hassle to spend countless hours providing after the fact such guidance in the code. As for compilers, you should strive to provide a documentation without any warning.
## Codespell ## Codespell
[codespell](https://github.com/codespell-project/codespell) is a very neat projet to check english errors in your code. It may be used upon code directly or upon the associated README and is rather helpful to notice typos or some english errors (for instance it found out we used _informations_ a lot in these notebooks whereas it is incorrect and should be _information_). [codespell](https://github.com/codespell-project/codespell) is a very neat projet to check english errors in your code. It may be used upon code directly or upon the associated README and is rather helpful to notice typos or some english errors (for instance it found out we used _informations_ a lot in these notebooks whereas it is incorrect and should be _information_).
A strong point for this tool is that it is very easy to use; no steep learning curve for it. A strong point for this tool is that it is very easy to use; no steep learning curve for it.
We wouldn't however advice to use the options to automatically correct your documents; there might be some false positive. We wouldn't however advice to use the options to automatically correct your documents; there might be some false positive.
## More... ## More...
Our colleagues at Inria Bordeaux also recommend some additional tools in the Inria SonarQube Our colleagues at Inria Bordeaux also recommend some additional tools in the Inria SonarQube
[documentation](https://sonarqube.inria.fr/pages/documentation.html#orgd4ab5b1). [documentation](https://sonarqube.inria.fr/pages/documentation.html#orgd4ab5b1).
We also mentioned in a notebook [include-what-you-use](https://include-what-you-use.org/) to help figure out which include declarations are truly required and when forward declaration may be used. We also mentioned in a notebook [include-what-you-use](https://include-what-you-use.org/) to help figure out which include declarations are truly required and when forward declaration may be used.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
[© Copyright](../COPYRIGHT.md) [© Copyright](../COPYRIGHT.md)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment