1. cppcheck 다운 및 설치
http://sourceforge.net/projects/cppcheck/
2. Visual Studio 설정
- [도구(T)] -> [외부 도구(E)] -> [추가]
3. 인수
--enable=all --enable=style -q --template vs $(ProjectDir)
-j [job count] : multithread로 체크
>> 파일 검사
Arguments : -j 8 --enable=warning,style,performance,portability,information --std=c++11 --inline-suppr --quiet --template="{file}({line}): {severity} ({id}): {message}" $(ItemPath)
>> 프로젝트 검사
Arguments : -j 8 --enable=warning,style,performance,portability,information --std=c++11 --inline-suppr --quiet --template="{file}({line}): {severity} ({id}): {message}" $(ProjectDir)
4. cppcheck 실행
- cppcheck 실행할 프로젝트 선택 후 [도구(T)] -> [cppcheck] 실행 하면 VS 출력창에 결과 출력
>> cppcheck 주요 검수 항목
- 배열 인덱스 참조 위반
- 생성자가 없는 클래스
- 생성자가 초기화하지 않는 변수
- 잘못된 메모리 초기화
- 베이스 크래스의 소멸자는 가상 함수로 선언하지 않는 경우
- 사용하지 않는 private 함수
- operator= 가 self의 레퍼런스를 반환하지 않는 경우
- operator= 가 자신과 동일한 타입의 객체를 할당하지 않는 경우
- obsolete (폐기된) 함수(mktemp, gets, scanf)를 사용하는 경우
- 메모리 누수
- sprintf를 잘못 사용하는 경우
- 숫자를 0으로 나누는 경우
- null 포인터를 역참조 하는 경우
- 초기화하지 않은 변수나 데이터를 사용하는 경우
- 입력 스트림에 fflush()를 사용하는 경우
- memset, memcpy 등이 클래스에서 사용될 때 경고
[출처] 정적 분석 도구 - Cppcheck |작성자 모리아
'Development > C/C++' 카테고리의 다른 글
Visual Studio 2015 Diagnostic Tools (0) | 2016.11.16 |
---|---|
[링크] C++의 소스파일 확장자인 .cxx, .hpp, .h, .hxx 차이 (0) | 2016.06.22 |
원격 디버깅 (VS.NET 2003) (0) | 2013.02.27 |
무료 C++ 개발환경(IDE) Dev-C++ (0) | 2013.02.27 |
Visual Studio.NET 2003에서 전처리 결과 소스 확인방법 (0) | 2013.02.27 |
![DNS server, DNS service](http://banner.dnsever.com/dnsever-banner_170x35.gif)