Compiler flags

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • spasmous

    Compiler flags

    Can someone point me to a website that lists the compiler flags for the
    Linux c++ compiler. Yes, I know it's called c++ but I am using it to
    compile .c files.

  • J. J. Farrell

    #2
    Re: Compiler flags


    spasmous wrote:
    Can someone point me to a website that lists the compiler flags for the
    Linux c++ compiler. Yes, I know it's called c++ but I am using it to
    compile .c files.
    There's a chap called Google who can be contacted at
    http://www.google.com - he knows all about that sort of thing.

    Comment

    • Richard Heathfield

      #3
      Re: Compiler flags

      J. J. Farrell said:
      >
      spasmous wrote:
      >Can someone point me to a website that lists the compiler flags for the
      >Linux c++ compiler. Yes, I know it's called c++ but I am using it to
      >compile .c files.
      >
      There's a chap called Google who can be contacted at
      http://www.google.com - he knows all about that sort of thing.
      That's like claiming that Mr Yellow Pages knows all about how to clean
      drains, bake bread, drive taxis, and issue passports.

      Google is a search engine, not an oracle. It doesn't know anything about
      Linux, C++, or compiler flags. In fact, it knows little more than which
      words appear on which Web sites. An intelligent Googler is well aware that
      there is an awful lot of misinformation on the Web, for which Google cannot
      reasonably be held responsible. Caveat surfer.

      --
      Richard Heathfield
      "Usenet is a strange place" - dmr 29/7/1999

      email: rjh at above domain (but drop the www, obviously)

      Comment

      • Keith Thompson

        #4
        Re: Compiler flags

        "spasmous" <spasmous@gmail .comwrites:
        Can someone point me to a website that lists the compiler flags for the
        Linux c++ compiler. Yes, I know it's called c++ but I am using it to
        compile .c files.
        <OT>
        The usual default compiler on Linux is gcc (it's actually a collection
        of compilers for several languages, with a shared backend). There's a
        command called "g++" that invokes it as a C compiler. Typically "cc"
        and "c++" are installed as aliases for "gcc" and "g++", respectively.

        If you want to compile C code, use a C compiler: either "gcc" or "cc",
        not "g++", or "c++".

        All this is explained in gcc documentation, which you can see by
        typing "info gcc" or by doing a Google search for "gcc documentation".
        </OT>

        If you have any more questions about gcc (that aren't answered by the
        documentation), try gnu.gcc.help. If you have questions about Linux,
        try one of the many Linux newsgroups, or perhaps comp.unix.progr ammer.
        If you have questions about the C language itself, this is the right
        place.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
        We must do something. This is something. Therefore, we must do this.

        Comment

        • jacob navia

          #5
          Re: Compiler flags

          spasmous a écrit :
          Can someone point me to a website that lists the compiler flags for the
          Linux c++ compiler. Yes, I know it's called c++ but I am using it to
          compile .c files.
          >
          You should learn to read the documentation.

          Just write:

          info gcc
          or
          man gcc

          and the associated documentation will tell you ALL compiler
          flags, and what they do.

          Comment

          • spasmous

            #6
            Re: Compiler flags


            jacob navia wrote:
            spasmous a écrit :
            Can someone point me to a website that lists the compiler flags for the
            Linux c++ compiler. Yes, I know it's called c++ but I am using it to
            compile .c files.
            >
            You should learn to read the documentation.
            >
            Just write:
            >
            info gcc
            or
            man gcc
            >
            and the associated documentation will tell you ALL compiler
            flags, and what they do.
            Thanks - I didn't realize c++ was an alias of gcc. Sometimes, you know,
            you have to compile someone else's programs on a platform that you
            don't know. man c++ was my first try, then google on Linux c++ compiler
            flags. Neither produced anything obviously useful.

            Next was look for the group with most hits on my google search and post
            there. Which is what I did. Sorry your NG is not pure enough for you
            guys - but thank you for your suggestions.

            Comment

            • Andrew Poelstra

              #7
              Re: Compiler flags

              "spasmous" <spasmous@gmail .comwrites:
              Can someone point me to a website that lists the compiler flags for the
              Linux c++ compiler. Yes, I know it's called c++ but I am using it to
              compile .c files.
              >
              Assuming you mean gcc, the appropriate flags are here (from Richard
              Heathfield at some point in the past):
              gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
              -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
              -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
              -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
              -Wno-conversion -O3

              Jacob Navia recommends adding -Wextra for the latest version of gcc.

              Rather unfortunately, you have to fix the spacing yourself.

              --
              Andrew Poelstra <http://www.wpsoftware. net/projects>
              To reach me by email, use `apoelstra' at the above domain.
              "Do BOTH ends of the cable need to be plugged in?" -Anon.

              Comment

              • Keith Thompson

                #8
                Re: Compiler flags

                Andrew Poelstra <apoelstra@fals e.sitewrites:
                "spasmous" <spasmous@gmail .comwrites:
                >
                >Can someone point me to a website that lists the compiler flags for the
                >Linux c++ compiler. Yes, I know it's called c++ but I am using it to
                >compile .c files.
                >>
                >
                Assuming you mean gcc, the appropriate flags are here (from Richard
                Heathfield at some point in the past):
                gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                -Wno-conversion -O3
                >
                Jacob Navia recommends adding -Wextra for the latest version of gcc.
                >
                Rather unfortunately, you have to fix the spacing yourself.
                <OT>
                -Wextra is a newer name for -W. "info gcc" for details.
                </OT>

                --
                Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
                We must do something. This is something. Therefore, we must do this.

                Comment

                • Richard Heathfield

                  #9
                  Re: Compiler flags

                  Andrew Poelstra said:
                  Assuming you mean gcc, the appropriate flags are here (from Richard
                  Heathfield at some point in the past):
                  gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                  -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                  -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                  -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                  -Wno-conversion -O3
                  No, this set is from "those who know me have no need of my name" - all I did
                  was pinch it. (And he's been looking for it ever since.)

                  --
                  Richard Heathfield
                  "Usenet is a strange place" - dmr 29/7/1999

                  email: rjh at above domain (but drop the www, obviously)

                  Comment

                  • CBFalconer

                    #10
                    Re: Compiler flags

                    Keith Thompson wrote:
                    Andrew Poelstra <apoelstra@fals e.sitewrites:
                    >"spasmous" <spasmous@gmail .comwrites:
                    >>
                    >>Can someone point me to a website that lists the compiler flags
                    >>for the Linux c++ compiler. Yes, I know it's called c++ but I am
                    >>using it to compile .c files.
                    >>
                    >Assuming you mean gcc, the appropriate flags are here (from Richard
                    >Heathfield at some point in the past):
                    >gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                    > -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                    > -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                    > -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                    > -Wno-conversion -O3
                    >>
                    >Jacob Navia recommends adding -Wextra for the latest version of gcc.
                    >>
                    >Rather unfortunately, you have to fix the spacing yourself.
                    >
                    <OT>
                    -Wextra is a newer name for -W. "info gcc" for details.
                    </OT>
                    Here is my set, implemented via an alias:

                    -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

                    --
                    Chuck F (cbfalconer at maineline dot net)
                    Available for consulting/temporary embedded and systems.
                    <http://cbfalconer.home .att.net>



                    --
                    Posted via a free Usenet account from http://www.teranews.com
                    Warning: Do not use Ultimate-Anonymity
                    They are worthless spammers that are running a scam.

                    Comment

                    • Harald van Dijk

                      #11
                      Re: Compiler flags

                      CBFalconer wrote:
                      Here is my set, implemented via an alias:
                      >
                      -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
                      I know you're not the first to recommend it, but please keep in mind
                      that gcc with the -Wwrite-strings option by design does not conform to
                      any standard. (Without that option, it still has bugs, but at least it
                      tries to be conforming.)

                      Comment

                      • Richard Heathfield

                        #12
                        Re: Compiler flags

                        Harald van D?k said:
                        CBFalconer wrote:
                        >Here is my set, implemented via an alias:
                        >>
                        >-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
                        >
                        I know you're not the first to recommend it, but please keep in mind
                        that gcc with the -Wwrite-strings option by design does not conform to
                        any standard.
                        Why not? All that -Wwrite-strings does is issue an extra diagnostic message
                        under certain circumstances, and implementations are allowed to issue
                        whatever diagnostic messages they like.

                        --
                        Richard Heathfield
                        "Usenet is a strange place" - dmr 29/7/1999

                        email: rjh at above domain (but drop the www, obviously)

                        Comment

                        • Harald van Dijk

                          #13
                          Re: Compiler flags

                          Richard Heathfield wrote:
                          Harald van D?k said:
                          CBFalconer wrote:
                          Here is my set, implemented via an alias:
                          >
                          -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
                          I know you're not the first to recommend it, but please keep in mind
                          that gcc with the -Wwrite-strings option by design does not conform to
                          any standard.
                          >
                          Why not? All that -Wwrite-strings does is issue an extra diagnostic message
                          under certain circumstances, and implementations are allowed to issue
                          whatever diagnostic messages they like.
                          Not if they cause a strictly conforming program such as the below to no
                          longer compile.

                          int main(void) {
                          if(0) ++*"";
                          }

                          Comment

                          • Richard Heathfield

                            #14
                            Re: Compiler flags

                            Harald van D?k said:
                            Richard Heathfield wrote:
                            >Harald van D?k said:
                            CBFalconer wrote:
                            >Here is my set, implemented via an alias:
                            >>
                            >-W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1
                            >
                            I know you're not the first to recommend it, but please keep in mind
                            that gcc with the -Wwrite-strings option by design does not conform to
                            any standard.
                            >>
                            >Why not? All that -Wwrite-strings does is issue an extra diagnostic
                            >message under certain circumstances, and implementations are allowed to
                            >issue whatever diagnostic messages they like.
                            >
                            Not if they cause a strictly conforming program such as the below to no
                            longer compile.
                            >
                            int main(void) {
                            if(0) ++*"";
                            }
                            me@here:~/scratchcat foo.c
                            int main(void) {
                            if(0) ++*"";
                            }

                            me@here:~/scratchmake
                            gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                            -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                            -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                            -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                            -Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c
                            foo.c: In function `main':
                            foo.c:2: warning: increment of read-only location
                            foo.c:3: warning: control reaches end of non-void function
                            gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                            -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                            -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                            -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                            -Wno-conversion -ffloat-store -O2 -g -pg -o foo foo.o -lm

                            See? It still compiles.

                            --
                            Richard Heathfield
                            "Usenet is a strange place" - dmr 29/7/1999

                            email: rjh at above domain (but drop the www, obviously)

                            Comment

                            • Harald van Dijk

                              #15
                              Re: Compiler flags

                              Richard Heathfield wrote:
                              Harald van D?k said:
                              Richard Heathfield wrote:
                              Harald van D?k said:
                              CBFalconer wrote:
                              Here is my set, implemented via an alias:
                              >
                              -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+ -O1

                              I know you're not the first to recommend it, but please keep in mind
                              that gcc with the -Wwrite-strings option by design does not conform to
                              any standard.
                              >
                              Why not? All that -Wwrite-strings does is issue an extra diagnostic
                              message under certain circumstances, and implementations are allowed to
                              issue whatever diagnostic messages they like.
                              Not if they cause a strictly conforming program such as the below to no
                              longer compile.

                              int main(void) {
                              if(0) ++*"";
                              }
                              >
                              me@here:~/scratchcat foo.c
                              int main(void) {
                              if(0) ++*"";
                              }
                              >
                              me@here:~/scratchmake
                              gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                              -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                              -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                              -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                              -Wno-conversion -ffloat-store -O2 -g -pg -c -o foo.o foo.c
                              foo.c: In function `main':
                              foo.c:2: warning: increment of read-only location
                              foo.c:3: warning: control reaches end of non-void function
                              gcc -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
                              -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
                              -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
                              -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
                              -Wno-conversion -ffloat-store -O2 -g -pg -o foo foo.o -lm
                              >
                              See? It still compiles.
                              Interesting. It doesn't with gcc 3.3.6, 3.4.6, 4.0.3 or 4.1.1.
                              "increment of read-only location" is an unconditional error in all four
                              of those versions.

                              Comment

                              Working...