<추가 강좌 팁 요청> splint 사용하기.
사용한지 얼마안되서 아는게 거의 없지만,
우선 올립니다. :roll:
splint는 c 코드를 컴파일 전에 미리 에러검출 해주는 프로그램입니다.
제가 찾아 본것은 splint와 clint 인데.
clint는 오랫동안 업데이트를 안한것 같더군요.
더 좋은 툴이 있는지 모르겠습니다.
splint는 Secure Programming Lint 라고 합니다.
기본적으로 unused 변수, buffer overflower warning등을 보여줍니다.
보통 너무 많은 메세지 때문에 초반부터 질리시는 분들이 많습니다만,
옵션으로 warning을 줄일 수 있습니다.
간단한 사용법은
소스가 있는 디렉토리에 .splintrc 를 만들고,
다음과 같이 실행합니다.
$ splint [source.c|.h]
.splintrc 는 splint 의 옵션을 그대로 적습니다.
(실행때 직접 옵션을 줘도 되지만, 너무 귀찮고 힘들겁니다.)
환경설정 파일의 예입니다.
$ cat .splintrc
-I../include/ -warnposix -usevarargs -likelybool
간단히 설명하면, include 디렉토리에 "../include/ " 추가하고,
posix에 대한 워닝이 너무많아서 posix 워닝을 제거했습니다.
(옵션에서 +는 추가이고, -는 제거입니다.)
-usevarargs "varargs.h" 에대한 워닝 제거,
-likelybool "BOOL" 사용에 대한 워닝 제거.
실행결과의 예입니다.
Splint 3.1.1 --- 29 Oct 2003Spec file not found: 2.lcl
Cannot open file: 2.c
cindexdata.c: (in function main)
cindexdata.c:128:9: Unrecognized identifier: chkInit
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
cindexdata.c:157:62: Format argument 1 to fprintf (%x) expects unsigned int
gets int: optopt
To ignore signs in type comparisons use +ignoresigns
cindexdata.c:157:54: Corresponding format code
cindexdata.c:168:9: Test expression for if not boolean, type BOOL:
b_isBackground
Test expression type is not boolean or int. (Use -predboolint to inhibit
warning)
cindexdata.c:169:9: Unrecognized identifier: SIGHUP
cindexdata.c:169:2: Return value (type [function (int) returns void]) ignored:
좀 더 잘 사용하실줄 아시는 분이나,
더 좋은 툴을 알고 계신분은 답글 부탁드립니다.
감사합니다.
Re: <추가 강좌 팁 요청> splint 사용하기.
(Ф_Ф) 언제까지나 즐거울 수 있도록...
댓글 달기