manual: Added information about platform configuration

This commit is contained in:
Daniel Marjamäki 2016-01-09 10:23:17 +01:00
parent 7b99a00ce8
commit 26c8c0e09d
1 changed files with 61 additions and 22 deletions

View File

@ -12,9 +12,9 @@
<title>Introduction</title> <title>Introduction</title>
<para>Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers <para>Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers
and many other analysis tools, it doesn't detect syntax errors. Instead, Cppcheck and many other analysis tools, it doesn't detect syntax errors. Instead,
detects the types of bugs that the compilers normally fail to detect. Cppcheck detects the types of bugs that the compilers normally fail to
The goal is no false positives.</para> detect. The goal is no false positives.</para>
<para>Supported code and platforms:</para> <para>Supported code and platforms:</para>
@ -80,8 +80,8 @@
<programlisting>cppcheck path</programlisting> <programlisting>cppcheck path</programlisting>
<para>If "path" is a folder then cppcheck will recursively check all source files in <para>If "path" is a folder then cppcheck will recursively check all
this folder.</para> source files in this folder.</para>
<programlisting>Checking path/file1.cpp... <programlisting>Checking path/file1.cpp...
1/2 files checked 50% done 1/2 files checked 50% done
@ -92,8 +92,8 @@ Checking path/file2.cpp...
<section> <section>
<title>Excluding a file or folder from checking</title> <title>Excluding a file or folder from checking</title>
<para>To exclude a file or folder, there are two options. The first option <para>To exclude a file or folder, there are two options. The first
is to only provide the paths and files you want to check.</para> option is to only provide the paths and files you want to check.</para>
<programlisting>cppcheck src/a src/b</programlisting> <programlisting>cppcheck src/a src/b</programlisting>
@ -111,18 +111,22 @@ Checking path/file2.cpp...
<section> <section>
<title>Include paths</title> <title>Include paths</title>
<para>To add an include path, use <parameter class="command">-I</parameter>, followed by the path.</para> <para>To add an include path, use <parameter
class="command">-I</parameter>, followed by the path.</para>
<para>Cppcheck's preprocessor basically handles includes like any other preprocessor. <para>Cppcheck's preprocessor basically handles includes like any other
However, while other preprocessors stop working when they encounter a missing header, preprocessor. However, while other preprocessors stop working when they
cppcheck will just print an information message and continues parsing the code.</para> encounter a missing header, cppcheck will just print an information
message and continues parsing the code.</para>
<para>The purpose of this behaviour is that cppcheck is meant to work without <para>The purpose of this behaviour is that cppcheck is meant to work
necessarily seeing the entire code. Actually, it is recommended to not give all include without necessarily seeing the entire code. Actually, it is recommended
paths. While it is useful for cppcheck to see the declaration of a class when checking the to not give all include paths. While it is useful for cppcheck to see
implementation of its members, passing standard library headers is highly discouraged because the declaration of a class when checking the implementation of its
it will result in worse results and longer checking time. For such cases, .cfg files (see below) are the members, passing standard library headers is highly discouraged because
better way to provide information about the implementation of functions and types to cppcheck.</para> it will result in worse results and longer checking time. For such
cases, .cfg files (see below) are the better way to provide information
about the implementation of functions and types to cppcheck.</para>
</section> </section>
<section> <section>
@ -256,14 +260,49 @@ cppcheck --enable=all</programlisting>
<section> <section>
<title>Multithreaded checking</title> <title>Multithreaded checking</title>
<para>The option -j is used to specify the number of threads you want to <para>The option <literal>-j</literal> is used to specify the number of
use. For example, to use 4 threads to check the files in a threads you want to use. For example, to use 4 threads to check the
folder:</para> files in a folder:</para>
<programlisting>cppcheck -j 4 path</programlisting> <programlisting>cppcheck -j 4 path</programlisting>
<para>Please note that this will disable unusedFunction checking.</para> <para>Please note that this will disable unusedFunction checking.</para>
</section> </section>
<section>
<title>Platform</title>
<para>You should use a platform configuration that match your
target.</para>
<para>By default Cppcheck uses native platform configuration that works
well if your code is compiled and executed locally.</para>
<para>Cppcheck has builtin configurations for <literal>unix</literal>
and <literal>windows</literal> targets. You can easily use these with
the <literal>--platform</literal> command line flag.</para>
<para>You can also create your own custom platform configuration in a
xml file. Here is an example:</para>
<programlisting>&lt;?xml version="1"?&gt;
&lt;platform&gt;
&lt;char_bit&gt;8&lt;/char_bit&gt;
&lt;default-sign&gt;signed&lt;/default-sign&gt;
&lt;sizeof&gt;
&lt;short&gt;2&lt;/short&gt;
&lt;int&gt;4&lt;/int&gt;
&lt;long&gt;4&lt;/long&gt;
&lt;long-long&gt;8&lt;/long-long&gt;
&lt;float&gt;4&lt;/float&gt;
&lt;double&gt;8&lt;/double&gt;
&lt;long-double&gt;12&lt;/long-double&gt;
&lt;pointer&gt;4&lt;/pointer&gt;
&lt;size_t&gt;4&lt;/size_t&gt;
&lt;wchar_t&gt;2&lt;/wchar_t&gt;
&lt;/sizeof&gt;
&lt;/platform&gt;</programlisting>
</section>
</chapter> </chapter>
<chapter id="preprocessor-configurations"> <chapter id="preprocessor-configurations">
@ -299,8 +338,8 @@ cppcheck -DA --force file.c</programlisting>
<chapter> <chapter>
<title>XML output</title> <title>XML output</title>
<para>Cppcheck can generate output in <literal>XML</literal> format. <para>Cppcheck can generate output in <literal>XML</literal> format. There
There is an old <literal>XML</literal> format (version 1) and a new is an old <literal>XML</literal> format (version 1) and a new
<literal>XML</literal> format (version 2). Please use the new version if <literal>XML</literal> format (version 2). Please use the new version if
you can.</para> you can.</para>