cppcheck/gui/help/ch03.html

17 lines
3.1 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 3. Preprocessor configurations</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.1"><link rel="home" href="index.html" title="Cppcheck 1.44"><link rel="up" href="index.html" title="Cppcheck 1.44"><link rel="prev" href="ch02s08.html" title="Multithreaded checking"><link rel="next" href="ch04.html" title="Chapter 4. XML output"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. Preprocessor configurations</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s08.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 3. Preprocessor configurations"><div class="titlepage"><div><div><h2 class="title"><a name="id2588374"></a>Chapter 3. Preprocessor configurations</h2></div></div></div><p>By default Cppcheck will check all preprocessor configurations
(except those that has #error in them). This is the recommended
behaviour.</p><p>But if you want to manually limit the checking you can do so with
<code class="literal">-D</code>.</p><p>Beware that only the macros, which are given here and the macros
defined in source files and known header files are considered. That
excludes all the macros defined in some system header files, which are by
default not examined by cppcheck.</p><p>The usage: if you, for example, want to limit the checking so the
only configuration to check should be "DEBUG=1;__cplusplus" then something
like this can be used:</p><pre class="programlisting">cppcheck -DDEBUG=1 -D__cplusplus path</pre><p>An alternative for -D is to use #error.</p><pre class="programlisting">#if LIB_VERSION &lt;= 3
#error "lib version must be greater than 3"
#endif</pre><p>Using #error instead of -D have some advantages:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>the compiler will not be able to compile the code when invalid
defines are given. So #error makes your source code
safer/better.</p></li><li class="listitem"><p>Cppcheck will check all valid configurations instead of a single
configuration.</p></li><li class="listitem"><p>This information is added to the source code which means you
don't need to provide this information to Cppcheck (makes it simpler
to use Cppcheck)</p></li></ul></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s08.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Multithreaded checking </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. XML output</td></tr></table></div></body></html>