Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Error & Warning messages

Reply
Thread Tools

Error & Warning messages

 
 
Hans Vlems
Guest
Posts: n/a
 
      01-17-2013
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
 
Reply With Quote
 
 
 
 
Shao Miller
Guest
Posts: n/a
 
      01-17-2013
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
 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      01-17-2013
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
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-17-2013
James Kuyper <(E-Mail Removed)> 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.velocityreviews.com/forums/(E-Mail Removed) <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"
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      01-17-2013
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 .
 
Reply With Quote
 
Hans Vlems
Guest
Posts: n/a
 
      01-18-2013
On 17 jan, 21:05, Robert Wessel <(E-Mail Removed)> wrote:
> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <(E-Mail Removed)>
> 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
 
Reply With Quote
 
Hans Vlems
Guest
Posts: n/a
 
      01-18-2013
On 17 jan, 13:11, James Kuyper <(E-Mail Removed)> 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
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      01-18-2013
Hans Vlems wrote:
> On 17 jan, 21:05, Robert Wessel <(E-Mail Removed)> wrote:
>> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <(E-Mail Removed)>
>> 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

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      01-18-2013
Robert Wessel <(E-Mail Removed)> writes:
> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <(E-Mail Removed)>
> 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) (E-Mail Removed) <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"
 
Reply With Quote
 
Hans Vlems
Guest
Posts: n/a
 
      01-22-2013
On 18 jan, 21:36, Robert Wessel <(E-Mail Removed)> wrote:
> On Fri, 18 Jan 2013 01:23:10 -0800 (PST), Hans Vlems
>
>
>
>
>
> <(E-Mail Removed)> wrote:
> >On 17 jan, 21:05, Robert Wessel <(E-Mail Removed)> wrote:
> >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <(E-Mail Removed)>
> >> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: When running Ant on command line, how to not-show its WARNING messages and only show ERROR message? Roedy Green Java 5 12-13-2011 05:49 PM
Re: When running Ant on command line, how to not-show its WARNING messages and only show ERROR message? John B. Matthews Java 0 12-09-2011 05:19 PM
Compendiums of compiler warning/error messages mapped to actual codeproblems? David Mathog C Programming 7 01-11-2008 01:19 PM
Warning: WARNING Charles Computer Support 7 08-16-2005 09:07 PM
traceback with warning/error messages Jean Brouwers Python 2 07-18-2004 03:21 PM



Advertisments