Understood. I'll try to make a test, but it's not guaranteed :-(
I wonder if you volounteer to download simplecpp source code, build it, then run: $ simplecpp -DANY -I /tmp/R/include -I ... Hi, Daniel. I have attached the archive of /tmp/R/ (in r_testcase.tar.gz) to top-level post. If you have simplecpp already built, then you can just unpack archive into /tmp/ to be able to run the test case on your side. It might be more simple and straightforward then if I would build simplecpp on my side.
On the on hand I see that cppcheck tries to execute clang: $ cppcheck --clang=/bin/nonexistent --project=/tmp/R/chkr/bar.json Checking /tmp/R/bar/part_2/bar.c... Failed to execute '/bin/nonexistent -fsyntax-only -Xclang -ast-dump ... and even executes it: $ cppcheck --clang=/bin/clang --project=/tmp/R/chkr/bar.json Checking /tmp/R/bar/part_2/bar.c... Checking /tmp/R/bar/part_2/bar.c ... On the other hand the diagnostic messages persist that peculiar strictly to cppcheck's built-in C parser: $ cppcheck...
json project indicates directory: and file: for each compilation unit, so I we should be able to run $ cppcheck --project=/path/to/bar.json and do not care of what directory is current for cppcheck now. However the results of checking may differ for different starting working directory. Let wrap into json project the command line $ cppcheck -DANY -I /tmp/R/include -I /tmp/R/bar/part_1 /tmp/R/bar/part_2/bar.c from [preprocessor includes wrong header files] topic of this forum. $ cat bar.json [ { "arguments":...
Suppose foo system library has headers: $ ls -go /path/to/foo/headers/ -rw-r--r-- 1 138 Jan 28 17:53 foo.h -rw-r--r-- 1 49 Jan 28 17:33 config.h and headers are this simple: $ cat config.h #ifndef FOO_CONFIG_H #define FOO_CONFIG_H #endif $ cat foo.h #ifndef FOO_PUBLIC_H #define FOO_PUBLIC_H #include "config.h" # ifndef FOO_CONFIG_H # error Foo was not configured # endif #endif Assume bar application chose to keep it's configuration in it's ownconfig.h. $ ls -go bar/*/* -rw-r--r-- 1 0 Jan 28 22:53...
Let's check this test.c: #if ((0x7fffffffffffffffL * 2UL) < 0) # error LOL #endif $ cppcheck -DANYTHING --enable=all test.c Checking test.c ... test.c:2:0: error: #error LOL [preprocessorErrorDirective] # error LOL ^ The more fun is that that the left operand may be unsigned and the expression continues to be negative from cppcheck point of view. The expressions below are also considered negative by cppcheck preprocessor: (0x7fffffffffffffffUL * 2UL) (0x7fffffffffffffffUL << 1UL) (0x7000000000000000UL...
Let check this test.c: #error BOOOOM int main(void) { return 0; } Suddenly, $ cppcheck --enable=all --error-exitcode=17 test.c; echo $? Checking test.c ... 0 Applies to version 2.3, current git (2020-12-28 b94a6d595), debian 10 on x64. I do not have a bugtracker account, so I report this here.
Let check this test.c: #if ((0xffffffffffffffffULL) % 0xFFFF) # error BOOOOM #endif int main(void) { return 0; } $ cppcheck --enable=all --error-exitcode=17 test.c ; echo $? Checking test.c ... 0 ... nice. But suddenly $ cppcheck --enable=all --error-exitcode=17 -DSOME test.c; echo $? Checking test.c ... test.c:2:0: error: #error BOOOOM [preprocessorErrorDirective] # error BOOOOM ^ 17 Applies to version 2.3, current git (2020-12-28 b94a6d595), debian 10 on x64. I do not have bugtracker account, so...