![]() |
Error & Warning messages
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 |
Re: Error & Warning messages
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 |
Re: Error & Warning messages
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 |
Re: Error & Warning messages
James Kuyper <jameskuyper@verizon.net> 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) kst-u@mib.org <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" |
Re: Error & Warning messages
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 . |
Re: Error & Warning messages
On 17 jan, 21:05, Robert Wessel <robertwess...@yahoo.com> wrote:
> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <grahn+n...@snipabacken.se> > 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 |
Re: Error & Warning messages
On 17 jan, 13:11, James Kuyper <jameskuy...@verizon.net> 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 |
Re: Error & Warning messages
Hans Vlems wrote:
> On 17 jan, 21:05, Robert Wessel <robertwess...@yahoo.com> wrote: >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <grahn+n...@snipabacken.se> >> 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 |
Re: Error & Warning messages
Robert Wessel <robertwessel2@yahoo.com> writes:
> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <grahn+nntp@snipabacken.se> > 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) kst-u@mib.org <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" |
Re: Error & Warning messages
On 18 jan, 21:36, Robert Wessel <robertwess...@yahoo.com> wrote:
> On Fri, 18 Jan 2013 01:23:10 -0800 (PST), Hans Vlems > > > > > > <hvl...@freenet.de> wrote: > >On 17 jan, 21:05, Robert Wessel <robertwess...@yahoo.com> wrote: > >> On 17 Jan 2013 18:40:35 GMT, Jorgen Grahn <grahn+n...@snipabacken.se> > >> 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 |
| All times are GMT. The time now is 01:03 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.