is -pedantic bad flag?

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

    is -pedantic bad flag?

    Hi!

    I write this code cos.c

    #include <math.h>
    #include <stdio.h>

    int main(void)
    {
    double c;
    c = cos(0);
    printf("cos(0): %f\n", c);
    return 0;
    }

    I compile normal and it work.

    I compile with -pedantic and it not work.

    Is -pedantic bad flag?

    Is code bug?

    I use lcc -pedantic cos.c and he warn

    Error cos.c: c:\lcc\include\ math.h: 36 Syntax error; missing semicolon before `_cosl'
    Warning cos.c: c:\lcc\include\ math.h: 36 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 99 Syntax error; missing semicolon before `fabsl'
    Warning cos.c: c:\lcc\include\ math.h: 99 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 100 redefinition of '_stdcall'
    Error cos.c: c:\lcc\include\ math.h: 99 Previous definition of '_stdcall' here
    Error cos.c: c:\lcc\include\ math.h: 100 Syntax error; missing semicolon before `fabsd'
    Warning cos.c: c:\lcc\include\ math.h: 100 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 101 redefinition of '_stdcall'
    Error cos.c: c:\lcc\include\ math.h: 100 Previous definition of '_stdcall' here
    Error cos.c: c:\lcc\include\ math.h: 101 Syntax error; missing semicolon before `fabsf'
    Warning cos.c: c:\lcc\include\ math.h: 101 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 103 redefinition of '_stdcall'
    Error cos.c: c:\lcc\include\ math.h: 101 Previous definition of '_stdcall' here
    Error cos.c: c:\lcc\include\ math.h: 103 Syntax error; missing semicolon before `_fabsi'
    Warning cos.c: c:\lcc\include\ math.h: 103 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 104 Syntax error; missing semicolon before `_fabsull'
    Warning cos.c: c:\lcc\include\ math.h: 104 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 105 Syntax error; missing semicolon before `_fabsll'
    Warning cos.c: c:\lcc\include\ math.h: 105 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 106 Syntax error; missing semicolon before `_fabsu'
    Warning cos.c: c:\lcc\include\ math.h: 106 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 272 redefinition of '_stdcall'
    Error cos.c: c:\lcc\include\ math.h: 106 Previous definition of '_stdcall' here
    Error cos.c: c:\lcc\include\ math.h: 272 Syntax error; missing semicolon before `_signbit'
    Warning cos.c: c:\lcc\include\ math.h: 272 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ math.h: 346 redefinition of '_stdcall'
    Error cos.c: c:\lcc\include\ math.h: 272 Previous definition of '_stdcall' here
    Error cos.c: c:\lcc\include\ math.h: 346 Syntax error; missing semicolon before `_rint'
    Warning cos.c: c:\lcc\include\ math.h: 346 no type specified. Defaulting to int
    Error cos.c: c:\lcc\include\ tgmath.h: 30 too many errors

    Is better not use -pedantic? People say -pedantic is good.


  • Richard Heathfield

    #2
    Re: is -pedantic bad flag?

    new to c said:
    Hi!
    >
    I write this code cos.c
    >
    #include <math.h>
    #include <stdio.h>
    >
    int main(void)
    {
    double c;
    c = cos(0);
    printf("cos(0): %f\n", c);
    return 0;
    }
    >
    I compile normal and it work.
    The code is fine.
    I compile with -pedantic and it not work.
    >
    Is -pedantic bad flag?
    Not in gcc, it isn't. The only diagnostic message I can persuade gcc to
    emit for the above code is "warning: passing arg 1 of `cos' as floating
    rather than integer due to prototype", and it does have a point, but it's
    pretty clear that this isn't a showstopper.
    Is code bug?
    No, the code is fine.
    >
    I use lcc -pedantic cos.c and he warn
    >
    Error cos.c: c:\lcc\include\ math.h: 36 Syntax error; missing semicolon
    before `_cosl'
    Then you have a broken compiler. I suggest you switch to something that
    works, such as gcc.
    Is better not use -pedantic? People say -pedantic is good.
    In gcc, it's fine. But then, gcc (when invoked with appropriate flags, of
    which -pedantic is one) is a C compiler, which is always a good thing to
    start with if you want to compile C programs.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • Martin Ambuhl

      #3
      Re: is -pedantic bad flag?

      new to c wrote:
      Hi!
      >
      I write this code cos.c
      >
      #include <math.h>
      #include <stdio.h>
      >
      int main(void)
      {
      double c;
      c = cos(0);
      printf("cos(0): %f\n", c);
      return 0;
      }
      >
      I compile normal and it work.
      >
      I compile with -pedantic and it not work.
      >
      Is -pedantic bad flag?
      With a working compiler and a clean library using -pedantic (or its
      equivalent) is a good thing. -pedantic with gcc will cause a problem
      with the above.
      >
      Is code bug?
      No.
      >
      I use lcc -pedantic cos.c and he warn
      It seems that there is something wrong with the lcc implementation, then.
      Error cos.c: c:\lcc\include\ math.h: 36 Syntax error; missing semicolon before `_cosl'
      And this (and similar messages I have not quoted) suggests that the
      error is either with the provided <math.hor with the compiler.

      Is better not use -pedantic? People say -pedantic is good.
      Normally, -pedantic is a good thing to use. It appears that using your
      copy of lcc is a bad idea. It is possible that the current versions, or
      even yours installed correctly, will not have this problem. Check the
      lcc (or lcc-win32, if you're using Jacob's port) to make sure that you
      have the latest copy and have installed it correctly. It those these
      are true, then stop using lcc.

      Comment

      • Keith Thompson

        #4
        Re: is -pedantic bad flag?

        new to c <non@spam.inval idwrites:
        I write this code cos.c
        >
        #include <math.h>
        #include <stdio.h>
        >
        int main(void)
        {
        double c;
        c = cos(0);
        printf("cos(0): %f\n", c);
        return 0;
        }
        >
        I compile normal and it work.
        >
        I compile with -pedantic and it not work.
        >
        Is -pedantic bad flag?
        >
        Is code bug?
        >
        I use lcc -pedantic cos.c and he warn
        [snip]

        This is not a C language issue. You have a problem with lcc, or with
        your installation of it.

        The lcc compiler has its own newsgroup, comp.compilers. lcc. You
        should post your question there. Please specify whether you're using
        lcc or lcc-win (the latter is also known as lcc-win32), and which
        version.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        Nokia
        "We must do something. This is something. Therefore, we must do this."
        -- Antony Jay and Jonathan Lynn, "Yes Minister"

        Comment

        • Bartc

          #5
          Re: is -pedantic bad flag?

          "new to c" <non@spam.inval idwrote in message
          news:1483075.id cC6GMIco@news.a ioe.org...
          Hi!
          >
          I write this code cos.c
          >
          #include <math.h>
          #include <stdio.h>
          >
          int main(void)
          {
          double c;
          c = cos(0);
          printf("cos(0): %f\n", c);
          return 0;
          }
          >
          I compile normal and it work.
          >
          I compile with -pedantic and it not work.
          >
          Is -pedantic bad flag?
          >
          Is code bug?
          >
          I use lcc -pedantic cos.c and he warn
          >
          Error cos.c: c:\lcc\include\ math.h: 36 Syntax error; missing semicolon
          before `_cosl'
          Notice all the errors are for the header file?

          If you look at the math.h file, it uses special extensions like // comments
          and _stdcall.

          I would say there is a bug in this compiler because perhaps the -pedantic
          flag should be ignored when compiling it's own system headers (when you port
          your code elsewhere, you will use a different set of headers).

          Either forget -pedantic when using math.h (or whatever else), or ignore the
          warnings for this header, or switch compilers.

          --
          Bartc



          Comment

          • vippstar@gmail.com

            #6
            Re: is -pedantic bad flag?

            On Jun 21, 11:15 am, "Bartc" <b...@freeuk.co mwrote:
            "new to c" <n...@spam.inva lidwrote in messagenews:148 3075.idcC6GMIco @news.aioe.org. ..
            >
            >
            >
            Hi!
            >
            I write this code cos.c
            >
            #include <math.h>
            #include <stdio.h>
            >
            int main(void)
            {
            double c;
            c = cos(0);
            printf("cos(0): %f\n", c);
            return 0;
            }
            >
            I compile normal and it work.
            >
            I compile with -pedantic and it not work.
            >
            Is -pedantic bad flag?
            >
            Is code bug?
            >
            I use lcc -pedantic cos.c and he warn
            >
            Error cos.c: c:\lcc\include\ math.h: 36 Syntax error; missing semicolon
            before `_cosl'
            >
            Notice all the errors are for the header file?
            >
            If you look at the math.h file, it uses special extensions like // comments
            and _stdcall.
            // comments are not an extension, they are standarized with ISO C99.
            >
            I would say there is a bug in this compiler because perhaps the -pedantic
            flag should be ignored when compiling it's own system headers (when you port
            your code elsewhere, you will use a different set of headers).
            >
            Either forget -pedantic when using math.h (or whatever else), or ignore the
            warnings for this header, or switch compilers.
            I don't think they are warnings, warnings don't interrupt the
            compilation.
            I think Mr Navia should just fix the bug, because it *is* a bug, well,
            depending on what -pedantic says it does, but if it just provides more
            warnings/errors for standard C mode, then it's certainly a bug.

            Comment

            • Malcolm McLean

              #7
              Re: is -pedantic bad flag?


              "Martin Ambuhl" <mambuhl@earthl ink.netwrote in message
              Normally, -pedantic is a good thing to use. It appears that using your
              copy of lcc is a bad idea. It is possible that the current versions, or
              even yours installed correctly, will not have this problem. Check the lcc
              (or lcc-win32, if you're using Jacob's port) to make sure that you have
              the latest copy and have installed it correctly. It those these are true,
              then stop using lcc.
              >
              That's a bit dramatic, to stop using a compiler because one, admittedly
              quite useful, flag is broken.
              Most software has a few bugs that don't affect core functionality. Be glad
              that the bug doesn't silently affect the executables generated by lcc-win.
              That's a really nasty problem with compilers.

              --
              Free games and programming goodies.


              Comment

              • Richard Heathfield

                #8
                Re: is -pedantic bad flag?

                Malcolm McLean said:
                >
                "Martin Ambuhl" <mambuhl@earthl ink.netwrote in message
                >Normally, -pedantic is a good thing to use. It appears that using your
                >copy of lcc is a bad idea. It is possible that the current versions, or
                >even yours installed correctly, will not have this problem. Check the
                >lcc (or lcc-win32, if you're using Jacob's port) to make sure that you
                >have
                >the latest copy and have installed it correctly. It those these are
                >true, then stop using lcc.
                >>
                That's a bit dramatic, to stop using a compiler because one, admittedly
                quite useful, flag is broken.
                Where do you draw the line, then? Because this isn't the first lcc-win32
                bug, by any means, that has been reported in comp.lang.c in recent months.
                You say "one flag is broken", but we've seen that a great deal more is
                wrong, and we've seen that the maintainer is hostile to bug reports. When
                someone attacks his quality controllers, you can't help wondering whether
                the quality is actually there.
                Most software has a few bugs that don't affect core functionality. Be
                glad that the bug doesn't silently affect the executables generated by
                lcc-win.
                How do you know that?
                That's a really nasty problem with compilers.
                If so, then it *could* be a really nasty problem with this compiler too.
                I'm not saying it is, but we don't know it isn't.

                --
                Richard Heathfield <http://www.cpax.org.uk >
                Email: -http://www. +rjh@
                Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                "Usenet is a strange place" - dmr 29 July 1999

                Comment

                • Keith Thompson

                  #9
                  Re: is -pedantic bad flag?

                  Richard Heathfield <rjh@see.sig.in validwrites:
                  Malcolm McLean said:
                  >"Martin Ambuhl" <mambuhl@earthl ink.netwrote in message
                  >>Normally, -pedantic is a good thing to use. It appears that using your
                  >>copy of lcc is a bad idea. It is possible that the current versions, or
                  >>even yours installed correctly, will not have this problem. Check the
                  >>lcc (or lcc-win32, if you're using Jacob's port) to make sure that you
                  >>have
                  >>the latest copy and have installed it correctly. It those these are
                  >>true, then stop using lcc.
                  >>>
                  >That's a bit dramatic, to stop using a compiler because one, admittedly
                  >quite useful, flag is broken.
                  >
                  Where do you draw the line, then? Because this isn't the first lcc-win32
                  bug, by any means, that has been reported in comp.lang.c in recent months.
                  [...]

                  I've seen no evidence that the original post was referring to
                  lcc-win32. The poster referred to "lcc".

                  --
                  Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                  Nokia
                  "We must do something. This is something. Therefore, we must do this."
                  -- Antony Jay and Jonathan Lynn, "Yes Minister"

                  Comment

                  • Richard Heathfield

                    #10
                    Re: is -pedantic bad flag?

                    Keith Thompson said:
                    Richard Heathfield <rjh@see.sig.in validwrites:
                    >Malcolm McLean said:
                    >>"Martin Ambuhl" <mambuhl@earthl ink.netwrote in message
                    >>>Normally, -pedantic is a good thing to use. It appears that using
                    >>>your
                    >>>copy of lcc is a bad idea. It is possible that the current versions,
                    >>>or
                    >>>even yours installed correctly, will not have this problem. Check the
                    >>>lcc (or lcc-win32, if you're using Jacob's port) to make sure that you
                    >>>have
                    >>>the latest copy and have installed it correctly. It those these are
                    >>>true, then stop using lcc.
                    >>>>
                    >>That's a bit dramatic, to stop using a compiler because one, admittedly
                    >>quite useful, flag is broken.
                    >>
                    >Where do you draw the line, then? Because this isn't the first lcc-win32
                    >bug, by any means, that has been reported in comp.lang.c in recent
                    >months.
                    [...]
                    >
                    I've seen no evidence that the original post was referring to
                    lcc-win32. The poster referred to "lcc".
                    True enough, and a fair point, although the reaction from Mr Navia suggests
                    that this bug exists in lcc-win32 too. Generally, however, the point
                    remains - that it isn't just one bug that is the issue here. Nor is it
                    even many bugs. The real issue is one of how we respond to bug reports.

                    When you foul up and someone points it out, I know how you react - you
                    check to see whether the report is correct; if so, you thank the
                    pointer-outer for out-pointing, and if possible you fix the problem or at
                    least acknowledge it graciously. That's the right way. I would like to
                    think that I react (or at least try to react) in the same way.

                    Unfortunately, not everyone behaves in that way.

                    --
                    Richard Heathfield <http://www.cpax.org.uk >
                    Email: -http://www. +rjh@
                    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                    "Usenet is a strange place" - dmr 29 July 1999

                    Comment

                    • Bartc

                      #11
                      Re: is -pedantic bad flag?


                      "Richard Heathfield" <rjh@see.sig.in validwrote in message
                      news:j5OdncIUnZ BQX8DVnZ2dnUVZ8 uydnZ2d@bt.com. ..
                      Keith Thompson said:
                      >I've seen no evidence that the original post was referring to
                      >lcc-win32. The poster referred to "lcc".
                      >
                      True enough, and a fair point, although the reaction from Mr Navia
                      suggests
                      that this bug exists in lcc-win32 too. Generally, however, the point
                      remains - that it isn't just one bug that is the issue here. Nor is it
                      even many bugs. The real issue is one of how we respond to bug reports.
                      My experience is that lcc-win problems are dealt with promptly and helpfully
                      in comp.compilers. lcc.

                      Some issues I can work around by spending a few minutes investigating the
                      cause (rather than immediately post, inappropriately , to comp.lang.c), and
                      then I may possibly submit an observation to comp.compilers. lcc.

                      So I think it might be the attitude in this group that can produce the sort
                      of response you've seen. To quote from your own post in this thread:
                      Then you have a broken compiler. I suggest you switch to something that
                      works, such as gcc.
                      But then, gcc (when invoked with appropriate flags, of
                      which -pedantic is one) is a C compiler, which is always a good thing to
                      start with if you want to compile C programs.
                      I think /I/ would start to get angry too, at dismissing a considerable body
                      of work just like that.

                      --
                      Bartc






                      Comment

                      • Richard Heathfield

                        #12
                        Re: is -pedantic bad flag?

                        Bartc said:
                        >
                        "Richard Heathfield" <rjh@see.sig.in validwrote in message
                        news:j5OdncIUnZ BQX8DVnZ2dnUVZ8 uydnZ2d@bt.com. ..
                        <snip>
                        >But then, gcc (when invoked with appropriate flags, of
                        >which -pedantic is one) is a C compiler, which is always a good thing to
                        >start with if you want to compile C programs.
                        >
                        I think /I/ would start to get angry too, at dismissing a considerable
                        body of work just like that.
                        I'm not dismissing it at all. I'm sure it's very useful for whatever it is
                        that it's very useful for. But last I heard it doesn't conform to C90 and
                        it doesn't conform to C99, so it's hard to justify calling it a C
                        compiler.

                        In any case, no matter how angry Mr Navia may be at *me* for pointing out a
                        few obvious facts, how does that justify his getting angry at other people
                        for raising bug reports?

                        --
                        Richard Heathfield <http://www.cpax.org.uk >
                        Email: -http://www. +rjh@
                        Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                        "Usenet is a strange place" - dmr 29 July 1999

                        Comment

                        • Malcolm McLean

                          #13
                          Re: is -pedantic bad flag?

                          "Richard Heathfield" <rjh@see.sig.in validwrote in message
                          Bartc said:
                          I'm not dismissing it at all. I'm sure it's very useful for whatever it is
                          that it's very useful for. But last I heard it doesn't conform to C90 and
                          it doesn't conform to C99, so it's hard to justify calling it a C
                          compiler.
                          >
                          To write MiniBasic I dug out my old BBC Basic handbook, junked Procs (add
                          too much complexity), gosub (useless) and read / data (too confusing), and
                          added array intialisers, which do much the same thing as read / data more
                          intutively.
                          I also rationalised a bit so that every function that returns a string has a
                          dollar sign appended to it, all variables are double precision, arrays can
                          be redimensioned, and computed goto is allowed - that last was maybe a
                          mistake.

                          The result was something that doesn't conform to any standard, but is pretty
                          clearly a BASIC interpreter.

                          --
                          Free games and programming goodies.


                          Comment

                          • Kenny McCormack

                            #14
                            Re: is -pedantic bad flag?

                            In article <BaKdnREUFOGJz8 PVnZ2dnUVZ8vSdn Z2d@bt.com>,
                            Malcolm McLean <regniztar@btin ternet.comwrote :
                            >"Richard Heathfield" <rjh@see.sig.in validwrote in message
                            >Bartc said:
                            >I'm not dismissing it at all. I'm sure it's very useful for whatever it is
                            >that it's very useful for. But last I heard it doesn't conform to C90 and
                            >it doesn't conform to C99, so it's hard to justify calling it a C
                            >compiler.
                            >>
                            >To write MiniBasic I dug out my old BBC Basic handbook, junked Procs (add
                            >too much complexity), gosub (useless) and read / data (too confusing), and
                            >added array intialisers, which do much the same thing as read / data more
                            >intutively.
                            >I also rationalised a bit so that every function that returns a string has a
                            >dollar sign appended to it, all variables are double precision, arrays can
                            >be redimensioned, and computed goto is allowed - that last was maybe a
                            >mistake.
                            >
                            >The result was something that doesn't conform to any standard, but is pretty
                            >clearly a BASIC interpreter.
                            No.

                            Not in the terminology (read: warped world view) of the CLC regs.
                            You should certainly know this by now.

                            Comment

                            • Keith Thompson

                              #15
                              Re: is -pedantic bad flag?

                              "Malcolm McLean" <regniztar@btin ternet.comwrite s:
                              "Richard Heathfield" <rjh@see.sig.in validwrote in message
                              >Bartc said:
                              >I'm not dismissing it at all. I'm sure it's very useful for whatever it is
                              >that it's very useful for. But last I heard it doesn't conform to C90 and
                              >it doesn't conform to C99, so it's hard to justify calling it a C
                              >compiler.
                              >>
                              To write MiniBasic I dug out my old BBC Basic handbook, junked Procs
                              (add too much complexity), gosub (useless) and read / data (too
                              confusing), and added array intialisers, which do much the same thing
                              as read / data more intutively.
                              I also rationalised a bit so that every function that returns a string
                              has a dollar sign appended to it, all variables are double precision,
                              arrays can be redimensioned, and computed goto is allowed - that last
                              was maybe a mistake.
                              >
                              The result was something that doesn't conform to any standard, but is
                              pretty clearly a BASIC interpreter.
                              And this has what exactly to do with C, the topic of this newsgroup?

                              I'm sure you're proud of your MiniBasic, but why advertise it here?

                              --
                              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                              Nokia
                              "We must do something. This is something. Therefore, we must do this."
                              -- Antony Jay and Jonathan Lynn, "Yes Minister"

                              Comment

                              Working...