리눅스 Makefile 명령어 옵션중 에러처리 옵션 질문 입니다.

dnjswns2942의 이미지

../demo/handler/h_arf.c: In function ‘handler_atomic_read_file’:
../demo/handler/h_arf.c:173:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat]
../demo/handler/h_awf.c: In function ‘handler_atomic_write_file’:
../demo/handler/h_awf.c:133:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat]

main.c: In function ‘AtomicReadFileAckHandler’:
main.c:142:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat]
main.c:296:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ [-Wformat]

main.c: In function ‘process_read_property_multiple’:
main.c:264:8: warning: unused variable ‘filename’ [-Wunused-variable]
main.c: In function ‘process_write_property’:
main.c:335:7: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
main.c: In function ‘main’:

main.c:587:4: warning: implicit declaration of function ‘trend_log_timer’ [-Wimplicit-function-declaration]

위와 같은 에러를 낸다고 해서 프로그램이 죽지는 않습니다.
지저분해보여서 위와 같은 에러를 발생시키지 않도록 하고 싶은데요.
Makefile 에서 -w 옵션을 넣어주면 발생하지 않는다고 해서 넣어줘 보았는데 여전히 에러가 발생하여 질문하게 되었습니다

# Default compiler settings
OPTIMIZATION = -Os
DEBUGGING =
#WARNINGS = -Wall -Wmissing-prototypes
ifeq (${BUILD},debug)
OPTIMIZATION = -O0
DEBUGGING = -g -DDEBUG_ENABLED=1
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
DEFINES += -DBIP_DEBUG
endif
endif
CFLAGS += -Wno-unused-variable $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(STANDARDS) $(INCLUDES) $(DEFINES)

all: library demos
.PHONY : all library demos clean

library:
$(MAKE) -s -C lib all

demos:
$(MAKE) -s -C demo all

jick의 이미지

warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat]

이건 32비트에서만 제대로 동작하고 64비트가 되면 프로그램이 깨질 테고요. (뭐 절대 64비트에서 돌릴 일이 없으시다면 또 모르겠습니다만...)

warning: implicit declaration of function ‘trend_log_timer’ [-Wimplicit-function-declaration]

이건 절대 무조건 절대로 잡아야 하는 종류의 에러인데요, 이걸 "프로그램 안 죽어요" 하고 놔두는 건 시한폭탄을 깔아놓는 거나 다름없습니다.

dnjswns2942의 이미지

경고 에러문 인지 아랐는데 무조건 잡아줘야 하는군요. 소스 한번더 확인해보고 고치도록 할게요^^ 조언 감사합니다.

김정균의 이미지

윗분말씀은 고려되어야 할 것이 맞기는 한데, 질문에 충실하자면, compiler 옵션에 -Wall 이 없으면 warning을 출력하지 않을텐데요.
일단 Makefile과 에러 메세지만 유추해서는 lib를 build할 때 발생하는 듯 싶은데, lib/Makefile 을 확인해 보시기 바랍니다. 아마도 compile 옵션에 -Wall 이 들어가 있을 겁니다.

dnjswns2942의 이미지

Wall 옵션은 찾아보니 없네요.ㅠ 다른 Makefile도 살펴봐야 겠네요^^ 조언 주셔서 감사 드립니다~

김정균의 이미지

아 좀더 보자면, Wall 만 warning을 출력하지 않습니다.

man gcc 명령을 실행하셔서, "Warning Option" 문자열을 검색 하셔서, warning 관련 옵션이 있는지 확인해 보시는 것이 더 정확할 겁니다. 예를 들어 -Wall 은 다음의 옵션을 주는 것과 동일합니다.

           -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat
           -Wchar-subscripts -Wimplicit-int -Wimplicit-function-declaration
           -Wcomment -Wformat -Wmain (only for C/ObjC and unless
           -ffreestanding) -Wmissing-braces -Wnonnull -Wparentheses
           -Wpointer-sign -Wreorder -Wreturn-type -Wsequence-point
           -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1
           -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas
           -Wunused-function -Wunused-label -Wunused-value -Wunused-variable
           -Wvolatile-register-var
dnjswns2942의 이미지

찾아보니

#WARNINGS = -Wall -Wmissing-prototypes

Warning 옵션이 있더군요.

답변 감사 드립니다.^^

pchero의 이미지

다른말이지만

개인적으로 개발할때는 늘 -Wall 을 추가하여 사용합니다.

척척척 숨어있는 버그를 최대한 신경써서 잡아준다는데, 기특하지 않나요? ㅎㅎㅎㅎ

---------------------------------
제일 왼쪽이 저입니다 :)

dnjswns2942의 이미지

네 버그를 최대한 신경써서 잡아주는데 너무 신경을 써줘서 그런지 안쓰는 변수명 이런것도 다 경고 띄어 주더라구용.ㅋㅋ

답변 감사드립니다^_^

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.