Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit fbbf8440 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Refactor a bit the demo about third party warnings.

parent b2e8c271
......@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Getting started in C++](/) - [C++ in a real environment](/notebooks/6-InRealEnvironment/0-main.ipynb) - [TP 17](/notebooks/6-InRealEnvironment/2b-TP.ipynb)"
"# [Getting started in C++](/) - [C++ in a real environment](./0-main.ipynb) - [TP 17](./2b-TP.ipynb)"
]
},
{
......@@ -23,7 +23,7 @@
"source": [
"### Introduction\n",
"\n",
"[This notebook](/notebooks/TP/HowTo.ipynb) explains very briefly your options to run the TP.\n",
"[This notebook](../TP/HowTo.ipynb) explains very briefly your options to run the TP.\n",
"\n",
"**WARNING:** Coliru is not an option here: you need to go the local or Docker way!"
]
......@@ -74,7 +74,7 @@
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2019_ \n",
"© _CNRS 2016_ - _Inria 2018-2020_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_"
]
......@@ -84,14 +84,14 @@
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xeus-cling-cpp17"
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "-std=c++17"
"version": "17"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
......
......@@ -14,7 +14,7 @@
},
"source": [
"<h1>Table of contents<span class=\"tocSkip\"></span></h1>\n",
"<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=\"#Example\" data-toc-modified-id=\"Example-2\">Example</a></span></li><li><span><a href=\"#Indicating-the-header-from-those-libraries-as-system-ones\" data-toc-modified-id=\"Indicating-the-header-from-those-libraries-as-system-ones-3\">Indicating the header from those libraries as system ones</a></span><ul class=\"toc-item\"><li><span><a href=\"#clangor-gcc-compiler\" data-toc-modified-id=\"clangor-gcc-compiler-3.1\"><code>clang</code>or <code>gcc</code> compiler</a></span></li><li><span><a href=\"#CMake\" data-toc-modified-id=\"CMake-3.2\">CMake</a></span></li></ul></li><li><span><a href=\"#Deactivating-locally-warning-with-pragmas-in-your-code\" data-toc-modified-id=\"Deactivating-locally-warning-with-pragmas-in-your-code-4\">Deactivating locally warning with pragmas in your code</a></span><ul class=\"toc-item\"><li><span><a href=\"#Extra-level-of-indirection\" data-toc-modified-id=\"Extra-level-of-indirection-4.1\">Extra level of indirection</a></span></li></ul></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=\"#Demo\" data-toc-modified-id=\"Demo-2\">Demo</a></span></li><li><span><a href=\"#Example\" data-toc-modified-id=\"Example-3\">Example</a></span></li><li><span><a href=\"#Indicating-the-header-from-those-libraries-as-system-ones\" data-toc-modified-id=\"Indicating-the-header-from-those-libraries-as-system-ones-4\">Indicating the header from those libraries as system ones</a></span><ul class=\"toc-item\"><li><span><a href=\"#clangor-gcc-compiler\" data-toc-modified-id=\"clangor-gcc-compiler-4.1\"><code>clang</code>or <code>gcc</code> compiler</a></span></li><li><span><a href=\"#CMake\" data-toc-modified-id=\"CMake-4.2\">CMake</a></span></li></ul></li><li><span><a href=\"#Deactivating-locally-warning-with-pragmas-in-your-code\" data-toc-modified-id=\"Deactivating-locally-warning-with-pragmas-in-your-code-5\">Deactivating locally warning with pragmas in your code</a></span><ul class=\"toc-item\"><li><span><a href=\"#Extra-level-of-indirection\" data-toc-modified-id=\"Extra-level-of-indirection-5.1\">Extra level of indirection</a></span></li></ul></li></ul></div>"
]
},
{
......@@ -33,6 +33,13 @@
"* Of course, you may ask the library developers to fix it, or even better provide a **pull request** to do it for them... but they may not be keen to accept it, and argue they know what they're doing and that you should shut the damn compiler warning up. But you really shouldn't: the warnings you want to use or not should be dictated by your own needs, not by the third-party libraries.\n",
"* Letting the warning is also bad: as already mentioned if you're letting even 10 warnings in your code you may not see the dangerous 11th a change in the code may produce.\n",
"\n",
"## Demo\n",
"\n",
"We will follow here the instructions detailed in a dedicated [README](./4b-Demo/README.md).\n",
"\n",
"The remaining of current notebook is a shortcut if you do not want to run the demo; if you do you may stop reading here and switch to the demo.\n",
"\n",
"\n",
"## Example\n",
"\n",
"As we shall see, there are two very different mechanisms that are present to work around the issue.\n",
......
......@@ -20,5 +20,9 @@ int main()
return EXIT_FAILURE;
}
int a; // variable intentionally left to underline my point about warnings...
std::cout << "Value is " << a << std::endl;
return EXIT_SUCCESS;
}
../1-ProblematicCase/simple_boost.cpp
\ No newline at end of file
......@@ -41,5 +41,9 @@ int main()
return EXIT_FAILURE;
}
int a; // variable intentionally left to underline my point about warnings...
std::cout << "Value is " << a << std::endl;
return EXIT_SUCCESS;
}
......@@ -53,5 +53,10 @@ int main()
return EXIT_FAILURE;
}
int a; // variable intentionally left to underline my point about warnings...
std::cout << "Value is " << a << std::endl;
return EXIT_SUCCESS;
}
......@@ -19,5 +19,9 @@ int main()
return EXIT_FAILURE;
}
int a; // variable intentionally left to underline my point about warnings...
std::cout << "Value is " << a << std::endl;
return EXIT_SUCCESS;
}
......@@ -9,11 +9,11 @@ RUN mkdir -p Codes/ThirdPartyWarning && mkdir -p Codes/ThirdParty
WORKDIR Codes/ThirdParty
RUN wget https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz \
&& tar xzf boost_1_69_0.tar.gz \
&& rm -f boost_1_69_0.tar.gz
RUN wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz \
&& tar xzf boost_1_72_0.tar.gz \
&& rm -f boost_1_72_0.tar.gz
WORKDIR boost_1_69_0
WORKDIR boost_1_72_0
RUN ./bootstrap.sh cxxstd=14,17 --prefix=../opt --with-toolset=clang --with-libraries=filesystem,system
RUN ./b2 install link=static toolset=clang variant=debug
......
......@@ -11,10 +11,10 @@ Then to get the relevant image you may either:
Type in a terminal:
````
docker build -t third_party_warning .
docker build -t demo_third_party_warning .
````
This may take few minutes
This may take few minutes.
### Or fetching it from the gitlab registry
......@@ -22,7 +22,7 @@ Type in a terminal (provided you have an account on the [Inria gitlab](https://g
````
docker login registry.gitlab.inria.fr
docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/third_party_warning:latest
docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/demo_third_party_warning:latest
````
## Running the image
......@@ -30,7 +30,7 @@ docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/
Go in the _Docker/ThirdPartyWarning_ folder and type:
````
docker run -v $PWD:/Codes/ThirdPartyWarning --cap-drop=all -it third_party_warning
docker run -v $PWD:/Codes/ThirdPartyWarning --cap-drop=all -it demo_third_party_warning
````
For those of you not familiar with Docker:
......@@ -67,7 +67,7 @@ cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX
ninja
````
At the time of this writing, I get 1174 warnings!
At the time of this writing, I get 1355 warnings! (more than in the first run one year ago with Boost 1.69...)
## First solution: system directories
......@@ -130,7 +130,7 @@ ninja
and we get two type of warnings:
* -Wsign-conversion that were present in clang and fixed by the pragmas
* -Wunknown-pragmas as pragmas used for clang build are not recognized! So fixing for clang makes it worse for gcc..
* -Wunknown-pragmas as pragmas used for clang build are not recognized! So fixing for clang makes it somehwat worse for gcc.. (not completely - some ignored warnings do also exist in gcc and were therefore silenced).
### Fixing clang AND gcc warnings
......
FROM fedora:latest
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
RUN (dnf update -y && dnf upgrade -y -q)
RUN dnf install -y git cmake clang && dnf clean packages
ENTRYPOINT ["bash"]
\ No newline at end of file
FROM fedora:latest
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
RUN (dnf update -y && dnf upgrade -y -q)
RUN dnf install -y git cmake gcc gcc-c++ gcc-gfortran && dnf clean packages
ENTRYPOINT ["bash"]
\ No newline at end of file
FROM ubuntu:latest
LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
# Update of the distribution
RUN (apt-get update && apt-get upgrade -y -q && apt-get dist-upgrade -y -q && apt-get -y -q autoclean && apt-get -y -q autoremove)
# ---------------------------------------
# Install recent version of gcc and g++
# ---------------------------------------
# To provide add-apt-repository
RUN apt-get install --no-install-recommends -y software-properties-common
ENV GCC_VERSION 8
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update \
&& apt-get install -y gcc-$GCC_VERSION g++-$GCC_VERSION gfortran-$GCC_VERSION
RUN apt-get install -y --no-install-recommends git cmake make sudo
# Just now set gcc to the latest version (if this command was run before the apt-get install it would have beem reversed...)
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 100 --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-$GCC_VERSION
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment