From 6c1bb7659952b1d967c367c4177ff24752c2175e Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 29 Oct 2014 11:35:47 +0100 Subject: [PATCH] Improved documentation of .cfg files. --- man/manual.docbook | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/man/manual.docbook b/man/manual.docbook index bb7d507ae..ec355c0cf 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -849,7 +849,7 @@ Checking noreturn.c...
use-retval - Per default, cppcheck assumes that ignoring the return value of a function is ok: + As long as nothing else is specified, cppcheck assumes that ignoring the return value of a function is ok: bool test(const char* a, const char* b) { @@ -879,6 +879,47 @@ Checking useretval.c... </def>
+
+ define + + Libraries can be used to define preprocessor macros as well. For example: + + <?xml version="1.0"?> +<def> + <define name="NULL_VALUE" value="0"/> +</def> + + Each occurence of "NULL_VALUE" in the code would then be replaced by "0" at preprocessor stage. +
+ +
+ podtype + + Lots of code relies on typedefs providing platform independant types. "podtype"-tags can be used to provide necessary information to cppcheck to support them. Without further information, cppcheck does not understand the type "uint16_t" in the following example: + + void test() { + uint16_t a; +} + + No message about variable 'a' being unused is printed: + + # cppcheck --enable=style unusedvar.cpp +Checking unusedvar.cpp... + + If uint16_t is defined in a library as follows, the result improves: + + <?xml version="1.0"?> +<def> + <podtype name="uint16_t" sign="u" size="2"/> +</def> + + The size of the type is specified in bytes. Possible values for the "sign" attribute are "s" (signed) and "u" (unsigned). Both attributes are optional. Using this library, cppcheck prints: + + # cppcheck --library=lib.cfg --enable=style unusedvar.cpp +Checking unusedvar.cpp... +[unusedvar.cpp:2]: (style) Unused variable: a +
+
Example configuration for strcpy()