Error & Warning messages

H

Hans Vlems

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
 
S

Shao Miller

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.
 
J

James Kuyper

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.
 
K

Keith Thompson

James Kuyper said:
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.
 
J

Jorgen Grahn

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
 
H

Hans Vlems

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
 
H

Hans Vlems

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:



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, 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
 
K

Keith Thompson

Robert Wessel said:
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.)
 
H

Hans Vlems

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
 
H

Hans Vlems

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 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.


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top