From 26c8c0e09d981668e417aefdf079196e6a61adc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 9 Jan 2016 10:23:17 +0100 Subject: [PATCH] manual: Added information about platform configuration --- man/manual.docbook | 83 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/man/manual.docbook b/man/manual.docbook index ede71aecf..eb1400d28 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -12,9 +12,9 @@ Introduction 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 - detects the types of bugs that the compilers normally fail to detect. - The goal is no false positives. + and many other analysis tools, it doesn't detect syntax errors. Instead, + Cppcheck detects the types of bugs that the compilers normally fail to + detect. The goal is no false positives. Supported code and platforms: @@ -80,8 +80,8 @@ cppcheck path - If "path" is a folder then cppcheck will recursively check all source files in - this folder. + If "path" is a folder then cppcheck will recursively check all + source files in this folder. Checking path/file1.cpp... 1/2 files checked 50% done @@ -92,8 +92,8 @@ Checking path/file2.cpp...
Excluding a file or folder from checking - To exclude a file or folder, there are two options. The first option - is to only provide the paths and files you want to check. + To exclude a file or folder, there are two options. The first + option is to only provide the paths and files you want to check. cppcheck src/a src/b @@ -111,18 +111,22 @@ Checking path/file2.cpp...
Include paths - To add an include path, use -I, followed by the path. + To add an include path, use -I, followed by the path. - Cppcheck's preprocessor basically handles includes like any other preprocessor. - However, while other preprocessors stop working when they encounter a missing header, - cppcheck will just print an information message and continues parsing the code. + Cppcheck's preprocessor basically handles includes like any other + preprocessor. However, while other preprocessors stop working when they + encounter a missing header, cppcheck will just print an information + message and continues parsing the code. - The purpose of this behaviour is that cppcheck is meant to work without - necessarily seeing the entire code. Actually, it is recommended to not give all include - paths. While it is useful for cppcheck to see the declaration of a class when checking the - implementation of its members, passing standard library headers is highly discouraged because - 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. + The purpose of this behaviour is that cppcheck is meant to work + without necessarily seeing the entire code. Actually, it is recommended + to not give all include paths. While it is useful for cppcheck to see + the declaration of a class when checking the implementation of its + members, passing standard library headers is highly discouraged because + 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.
@@ -256,14 +260,49 @@ cppcheck --enable=all
Multithreaded checking - The option -j is used to specify the number of threads you want to - use. For example, to use 4 threads to check the files in a - folder: + The option -j is used to specify the number of + threads you want to use. For example, to use 4 threads to check the + files in a folder: cppcheck -j 4 path Please note that this will disable unusedFunction checking.
+ +
+ Platform + + You should use a platform configuration that match your + target. + + By default Cppcheck uses native platform configuration that works + well if your code is compiled and executed locally. + + Cppcheck has builtin configurations for unix + and windows targets. You can easily use these with + the --platform command line flag. + + You can also create your own custom platform configuration in a + xml file. Here is an example: + + <?xml version="1"?> +<platform> + <char_bit>8</char_bit> + <default-sign>signed</default-sign> + <sizeof> + <short>2</short> + <int>4</int> + <long>4</long> + <long-long>8</long-long> + <float>4</float> + <double>8</double> + <long-double>12</long-double> + <pointer>4</pointer> + <size_t>4</size_t> + <wchar_t>2</wchar_t> + </sizeof> +</platform> +
@@ -299,8 +338,8 @@ cppcheck -DA --force file.c XML output - Cppcheck can generate output in XML format. - There is an old XML format (version 1) and a new + Cppcheck can generate output in XML format. There + is an old XML format (version 1) and a new XML format (version 2). Please use the new version if you can.