Error & Warning messages

Discussion in 'C Programming' started by Hans Vlems, Jan 17, 2013.

  1. Hans Vlems

    Hans Vlems Guest

    Some of our C programs are compiled and run on different platforms.
    Waht I'd like is advice which -W flag(s) would be the best across
    platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    as DEC C on VAX and Alpha VMS platforms).
    At the moment programs are compiled with:
    gcc -pedantic -std=c99 -o <executable> <sourcefile>
    However this results in warnings and / or errors on 32 bit Windows 7
    that are not seen on XP (32 bit) or vice versa.
    Example : printf("%s%c\n","Hello"); does not generate an error (which
    it should have done). gcc -Wall -std=c99 does trap this one.
    So -Wall checks more strictly than -pedantic?

    Hans
    Hans Vlems, Jan 17, 2013
    #1
    1. Advertising

  2. Hans Vlems

    Shao Miller Guest

    On 1/17/2013 03:03, Hans Vlems wrote:
    > Some of our C programs are compiled and run on different platforms.
    > Waht I'd like is advice which -W flag(s) would be the best across
    > platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > as DEC C on VAX and Alpha VMS platforms).
    > At the moment programs are compiled with:
    > gcc -pedantic -std=c99 -o <executable> <sourcefile>
    > However this results in warnings and / or errors on 32 bit Windows 7
    > that are not seen on XP (32 bit) or vice versa.
    > Example : printf("%s%c\n","Hello"); does not generate an error (which
    > it should have done). gcc -Wall -std=c99 does trap this one.
    > So -Wall checks more strictly than -pedantic?
    >
    > Hans
    >


    I usually use: gcc -ansi -pedantic -Wall -Wextra -Werror ...

    But if you're using C99, you'd switch '-ansi' with '-std=c99', as you
    already know. Different versions of GCC can yield different results, so
    if you want the same results, try making sure the GCC versions match.

    --
    - Shao Miller
    --
    "Thank you for the kind words; those are the kind of words I like to hear.

    Cheerily," -- Richard Harter
    Shao Miller, Jan 17, 2013
    #2
    1. Advertising

  3. Hans Vlems

    James Kuyper Guest

    On 01/17/2013 03:03 AM, Hans Vlems wrote:
    > Some of our C programs are compiled and run on different platforms.
    > Waht I'd like is advice which -W flag(s) would be the best across
    > platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > as DEC C on VAX and Alpha VMS platforms).
    > At the moment programs are compiled with:
    > gcc -pedantic -std=c99 -o <executable> <sourcefile>
    > However this results in warnings and / or errors on 32 bit Windows 7
    > that are not seen on XP (32 bit) or vice versa.
    > Example : printf("%s%c\n","Hello"); does not generate an error (which
    > it should have done). gcc -Wall -std=c99 does trap this one.
    > So -Wall checks more strictly than -pedantic?


    This is really a question about gcc rather than C, and as such you'll
    get better answers in a forum devoted to gcc, such as gnu.gcc.help.

    From the man page on my home desktop:
    > -Wall turns on the following warning flags:
    >
    > -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat
    > -Wchar-subscripts -Wenum-compare (in C/Objc; this is on by default
    > in C++) -Wimplicit-int (C and Objective-C only)
    > -Wimplicit-function-declaration (C and Objective-C only) -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


    So it turns on a LOT of warnings that -pedantic -std=c99 does not provide.

    My personal preference is for -std=c99 -pedantic -Wall -Pointer-arith
    -Wcast-align -Wstrict-prototypes -Wmissing-prototypes.
    --
    James Kuyper
    James Kuyper, Jan 17, 2013
    #3
  4. James Kuyper <> writes:
    [...]
    > My personal preference is for -std=c99 -pedantic -Wall -Pointer-arith
    > -Wcast-align -Wstrict-prototypes -Wmissing-prototypes.


    You mean -Wpointer-arith rather than -Pointer-arith.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Working, but not speaking, for JetHead Development, Inc.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jan 17, 2013
    #4
  5. Hans Vlems

    Jorgen Grahn Guest

    On Thu, 2013-01-17, Hans Vlems wrote:
    > Some of our C programs are compiled and run on different platforms.
    > Waht I'd like is advice which -W flag(s) would be the best across
    > platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > as DEC C on VAX and Alpha VMS platforms).


    People still use VMS? Cool.

    > At the moment programs are compiled with:
    > gcc -pedantic -std=c99 -o <executable> <sourcefile>
    > However this results in warnings and / or errors on 32 bit Windows 7
    > that are not seen on XP (32 bit) or vice versa.
    > Example : printf("%s%c\n","Hello"); does not generate an error (which
    > it should have done). gcc -Wall -std=c99 does trap this one.
    > So -Wall checks more strictly than -pedantic?


    Another possible explanation: in the standard library of one there's a
    gcc-specific declaration of printf() which tells the compiler how to
    do the type checking, and it's not there on the other. See the
    "function attributes" section of the Gcc manual.

    If you create your own printf-like wrappers and you use gcc a lot,
    it's a good idea to provide such things so they get checked. You
    don't want your error reporting logic to crash because of such a bug,
    at the very moment you need it.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
    Jorgen Grahn, Jan 17, 2013
    #5
  6. Hans Vlems

    Hans Vlems Guest

    On 17 jan, 21:05, Robert Wessel <> wrote:
    > On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <>
    > wrote:
    >
    > >On Thu, 2013-01-17, Hans Vlems wrote:
    > >> Some of our C programs are compiled and run on different platforms.
    > >> Waht I'd like is advice which -W flag(s) would be the best across
    > >> platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > >> as DEC C on VAX and Alpha VMS platforms).

    >
    > >People still use VMS?  Cool.

    >
    > Yes, although I think most users have migrated to IPF by now.


    I don't know what IPF is but stock exchanges, hospitals, airports and
    banks still
    use VMS, mainly on Itanium hardware though there are still a lot of
    Alpha's out there.
    Factories may even stick to VAX/VMS.
    Hans
    Hans Vlems, Jan 18, 2013
    #6
  7. Hans Vlems

    Hans Vlems Guest

    On 17 jan, 13:11, James Kuyper <> wrote:
    > On 01/17/2013 03:03 AM, Hans Vlems wrote:
    >
    > > Some of our C programs are compiled and run on different platforms.
    > > Waht I'd like is advice which -W flag(s) would be the best across
    > > platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > > as DEC C on VAX and Alpha VMS platforms).
    > > At the moment programs are compiled with:
    > > gcc -pedantic -std=c99 -o <executable> <sourcefile>
    > > However this results in warnings and / or errors on 32 bit Windows 7
    > > that are not seen on XP (32 bit) or vice versa.
    > > Example : printf("%s%c\n","Hello"); does not generate an error (which
    > > it should have done). gcc -Wall -std=c99 does trap this one.
    > > So -Wall checks more strictly than -pedantic?

    >
    > This is really a question about gcc rather than C, and as such you'll
    > get better answers in a forum devoted to gcc, such as gnu.gcc.help.
    >
    > From the man page on my home desktop:
    >
    > > -Wall turns on the following warning flags:

    >
    > >            -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat
    > >            -Wchar-subscripts -Wenum-compare (in C/Objc; this is on by default
    > >            in C++) -Wimplicit-int (C and Objective-C only)
    > >            -Wimplicit-function-declaration (C and Objective-C only) -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

    >
    > So it turns on a LOT of warnings that -pedantic -std=c99 does not provide.
    >
    > My personal preference is for  -std=c99 -pedantic -Wall -Pointer-arith
    > -Wcast-align -Wstrict-prototypes -Wmissing-prototypes.
    > --
    > James Kuyper
    >
    >


    James, thanks for you suggestion. I compiled a couple of sources with
    the compiler
    options you suggested (including Keith's modification). No new
    problems but at least
    consitency between the Wintel platforms.
    Hans
    Hans Vlems, Jan 18, 2013
    #7
  8. Hans Vlems wrote:
    > On 17 jan, 21:05, Robert Wessel <> wrote:
    >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <>
    >> wrote:
    >>
    >>> On Thu, 2013-01-17, Hans Vlems wrote:
    >>>> Some of our C programs are compiled and run on different platforms.
    >>>> Waht I'd like is advice which -W flag(s) would be the best across
    >>>> platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as
    >>>> well as DEC C on VAX and Alpha VMS platforms).

    >>
    >>> People still use VMS? Cool.

    >>
    >> Yes, although I think most users have migrated to IPF by now.

    >
    > I don't know what IPF is


    Itanium Processor Family

    > but stock exchanges, hospitals, airports and
    > banks still
    > use VMS, mainly on Itanium hardware though there are still a lot of
    > Alpha's out there.
    > Factories may even stick to VAX/VMS.
    > Hans
    Joachim Schmitz, Jan 18, 2013
    #8
  9. Robert Wessel <> writes:
    > On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <>
    > wrote:
    >>On Thu, 2013-01-17, Hans Vlems wrote:
    >>> Some of our C programs are compiled and run on different platforms.
    >>> Waht I'd like is advice which -W flag(s) would be the best across
    >>> platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    >>> as DEC C on VAX and Alpha VMS platforms).

    >>
    >>People still use VMS? Cool.

    >
    > Yes, although I think most users have migrated to IPF by now.


    To clarify, you mean they've migrated from VMS (the OS) on VAX and Alpha
    (CPU architectures) to VMS (same OS, probably another version) on IPF
    (Itanium Processor Family, previously called IA-64) (another CPU
    architecture), yes?

    I initially assumed that IPF was a newer OS that replaces VMS -- and "IPF"
    turns out to be difficult to Google.

    (Oh, and VMS is officially called OpenVMS.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Working, but not speaking, for JetHead Development, Inc.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jan 18, 2013
    #9
  10. Hans Vlems

    Hans Vlems Guest

    On 18 jan, 21:36, Robert Wessel <> wrote:
    > On Fri, 18 Jan 2013 01:23:10 -0800 (PST), Hans Vlems
    >
    >
    >
    >
    >
    > <> wrote:
    > >On 17 jan, 21:05, Robert Wessel <> wrote:
    > >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <>
    > >> wrote:

    >
    > >> >On Thu, 2013-01-17, Hans Vlems wrote:
    > >> >> Some of our C programs are compiled and run on different platforms.
    > >> >> Waht I'd like is advice which -W flag(s) would be the best across
    > >> >> platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > >> >> as DEC C on VAX and Alpha VMS platforms).

    >
    > >> >People still use VMS?  Cool.

    >
    > >> Yes, although I think most users have migrated to IPF by now.

    >
    > >I don't know what IPF is but stock exchanges, hospitals, airports and
    > >banks still
    > >use VMS, mainly on Itanium hardware though there are still a lot of
    > >Alpha's out there.
    > >Factories may even stick to VAX/VMS.

    >
    > There are a surprising number of VAXen still out there.- Tekst uit oorspronkelijk bericht niet weergeven -
    >
    > - Tekst uit oorspronkelijk bericht weergeven -


    Yeah, at least 20 live in my own attic....
    Hans
    Hans Vlems, Jan 22, 2013
    #10
  11. Hans Vlems

    Hans Vlems Guest

    On 18 jan, 21:29, Robert Wessel <> wrote:
    > On Fri, 18 Jan 2013 08:23:31 -0800, Keith Thompson <>
    > wrote:
    >
    >
    >
    >
    >
    > >Robert Wessel <> writes:
    > >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <>
    > >> wrote:
    > >>>On Thu, 2013-01-17, Hans Vlems wrote:
    > >>>> Some of our C programs are compiled and run on different platforms.
    > >>>> Waht I'd like is advice which -W flag(s) would be the best across
    > >>>> platforms (gcc 4.6.2 for Windows 7 64 bits, Windows XP 32 bits as well
    > >>>> as DEC C on VAX and Alpha VMS platforms).

    >
    > >>>People still use VMS?  Cool.

    >
    > >> Yes, although I think most users have migrated to IPF by now.

    >
    > >To clarify, you mean they've migrated from VMS (the OS) on VAX and Alpha
    > >(CPU architectures) to VMS (same OS, probably another version) on IPF
    > >(Itanium Processor Family, previously called IA-64) (another CPU
    > >architecture), yes?

    >
    > Yes.  IPF is a pretty common name for the architecture in my
    > experience, although given that two people here didn't know it, its
    > usage may be somewhat more restricted than I thought.  I'll try to use
    > "Itanium" from now on.
    >
    > >I initially assumed that IPF was a newer OS that replaces VMS -- and "IPF"
    > >turns out to be difficult to Google.

    >
    > I just tried it.  Surprisingly so.  Probably not as bad as IBM's
    > current name for the AS/400 OS: "IBM i".  Dumbest product name ever.
    >
    > >(Oh, and VMS is officially called OpenVMS.)

    >
    > Yeah, and I call z/OS "MVS" too.  And when I'm being grumpy, I'll
    > still call her "Ozzy".- Tekst uit oorspronkelijk bericht niet weergeven -
    >
    > - Tekst uit oorspronkelijk bericht weergeven -


    Itanium is the name that is used in comp.os.vms and comp.sys.dec,
    though Itanic is
    popular in certain circles too.
    The operating system runs in te same version on two platforms. VMS
    V8.2 and upwards
    runs on Alpha and Itanium hardware.
    New developments on the os are pretty rare these days, when they
    happen they occur on
    both distributions. VAX/VMS stopped its development at V7.3.
    The prefix open is not voiced... Only marketing folks do pronounce
    it :)
    Hans
    Hans Vlems, Jan 22, 2013
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SXJmYW4gQWtyYW0=?=

    Displaying warning messages...

    =?Utf-8?B?SXJmYW4gQWtyYW0=?=, Dec 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    687
    =?Utf-8?B?SXJmYW4gQWtyYW0=?=
    Dec 27, 2004
  2. Jean Brouwers

    traceback with warning/error messages

    Jean Brouwers, Jul 17, 2004, in forum: Python
    Replies:
    2
    Views:
    501
    Jean Brouwers
    Jul 18, 2004
  3. David Mathog
    Replies:
    7
    Views:
    323
    Richard Tobin
    Jan 11, 2008
  4. John B. Matthews
    Replies:
    0
    Views:
    742
    John B. Matthews
    Dec 9, 2011
  5. Roedy Green
    Replies:
    5
    Views:
    2,268
    Gene Wirchenko
    Dec 13, 2011
Loading...

Share This Page