gcc compile할 때 옵션 관련 질문드립니다...

kangduel의 이미지

-ansi
-pedantic
-Wall

이 세가지 옵션은 어떤 역할을 하는 건가요??
제가 초보라서 잘 모르는게 넘 많아여--;

송지석의 이미지

man gcc

       -ansi  Support all ANSI standard C programs.

              This turns off certain features of GNU C that are incompatible with ANSI C, such  as  the  asm,
              inline  and  typeof keywords, and predefined macros such as unix and vax that identify the type
              of system you are using.  It also enables the undesirable and rarely used  ANSI  trigraph  fea-
              ture, and disallows `$' as part of identifiers.

              The  alternate  keywords __asm__, __extension__, __inline__ and __typeof__ continue to work de-
              spite `-ansi'.  You would not want to use them in an ANSI C program, of course, but it is  use-
              ful  to put them in header files that might be included in compilations done with `-ansi'.  Al-
              ternate predefined macros such as __unix__ and __vax__ are  also  available,  with  or  without
              `-ansi'.

              The  `-ansi'  option  does  not cause non-ANSI programs to be rejected gratuitously.  For that,
              `-pedantic' is required in addition to `-ansi'.

              The preprocessor predefines a macro __STRICT_ANSI__ when you  use  the  `-ansi'  option.   Some
              header  files  may  notice  this macro and refrain from declaring certain functions or defining
              certain macros that the ANSI standard doesn't call for; this is to avoid interfering  with  any
              programs that might use these names for other things.

       -pedantic
              Issue all the warnings demanded by strict ANSI standard C; reject all programs that use forbid-
              den extensions.

              Valid  ANSI  standard  C programs should compile properly with or without this option (though a
              rare few will require `-ansi').  However, without this option, certain GNU extensions and  tra-
              ditional  C  features are supported as well.  With this option, they are rejected.  There is no
              reason to use this option; it exists only to satisfy pedants.

              `-pedantic' does not cause warning messages for use of the alternate keywords whose names begin
              and end with `__'.  Pedantic warnings are also disabled in the expression that follows __exten-
              sion__.  However, only system header files should use these escape routes; application programs
              should avoid them.

       -Wall  All  of the above `-W' options combined.  These are all the options which pertain to usage that
              we recommend avoiding and that we believe is easy to avoid, even in conjunction with macros.

질문하시기 전에 man 페이지를 참고해주시기 바랍니다. :-)

ansi 옵션은 ANSI 표준으로 컴파일 하는거고 pedantic은 ANSI가 아닌 비표준 사양은 불평하는 메시지를 내라는 거고요.
Wall은 waning을 all 켜라는 겁니다. 컴파일 경고 메시지를 다 켜는 거죠.

pynoos의 이미지

송지석님께 딴지 걸려는 것은 아니구요.. :D

-Wall이 모든 경고를 다 켠다고 생각해도 무방할 정도로 많은 경고를 냅니다만,
흔히 아는 것 처럼 모든 경고를 다 키진 않습니다. :lol:
man page를 더 잘 읽어 보시면..

Quote:

The remaining `-W...' options are not implied by `-Wall' because they warn about constructions that we
consider reasonable to use, on occasion, in clean programs.

remaining "-W.." options에 무려 16개나 더 있군요..
wowlinux 7.1에서 2.96으로 man 해보았습니다.

참고하세요..

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.