It might be either static or dynamic analysis, preferably free.
Asked
Active
Viewed 155 times
2
-
I honestly like just using gcc's output. I feel like it makes you learn more by not seeing code go wrong until you compile. Plus, you can't beat the suspense! – KrisSodroski Aug 14 '13 at 13:20
-
I prefer the compiler. With extra warnings turned on, modern compilers are pretty good at finding problems. – Some programmer dude Aug 14 '13 at 13:20
-
http://stackoverflow.com/questions/141498/what-open-source-c-static-analysis-tools-are-available – devnull Aug 14 '13 at 13:20
-
@devnull C is not C++. – Pascal Cuoq Aug 14 '13 at 13:23
-
@PascalCuoq I know that but the link does mention tools like splint that are meant for C, in addition to describing compiler flags that might help. – devnull Aug 14 '13 at 13:27
-
@Joe: Windows or Linux. – user2656304 Aug 14 '13 at 14:38
-
Coccinelle helped me find many errors, even though it's very simple. – user2656304 Aug 16 '13 at 12:34
1 Answers
3
cppcheck checks both C and C++ code and finds many errors.
Valgrind is a tool for runtime analysis, but I mention it anyway. It is extremely useful for tracking memory errors like uninitialized usage or leaks.
Also, activate ALL warnings your compiler has (GCC and clang:
-Wall -Wpedantic -Wextra
), which often reveals useful info.Note: clang sometimes generates much better warnings/errors than GCC
To find logic errors, however, testing is required. Testing is required anyway, something that is not tested is per definition broken, as you cannot assume it works.
Wikipedia has a list of C unit testing software.

dom0
- 7,356
- 3
- 28
- 50