Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gfortran -W switch?

43 views
Skip to first unread message

Erik Toussaint

unread,
Apr 29, 2009, 2:45:05 PM4/29/09
to
Hello,

on the 'Gettting started with gfortran' page at the gcc wiki,
http://gcc.gnu.org/wiki/GFortranGettingStarted
in the 'Standard conformance and other warnings' section, the following
commandline is recommended:

gfortran -std=f95 -W -Wall -pedantic mycode.f

I can't find a description of the -W switch in the gfortran
documentation ( http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gfortran/ ).
Does anyone here know what exactly it means/does?

Thanks,
Erik.

Jason Blevins

unread,
Apr 29, 2009, 3:00:39 PM4/29/09
to

gfortran is part of gcc, the GNU C compiler, and shares many
options with gcc itself (it seems they share a common frontend).
When I can't find an option in the gfortran manpage, I usually
turn to the gcc one.

According to the gcc manpage, despite the name, there is a set of
warnings that -Wall does not enable. The -W option turns those
additional ones on. Here's the relevant bit of documentation
(with the complete list omitted):

The following -W... options are not implied by -Wall. Some
of them warn about constructions that users generally do not
consider questionable, but which occasionally you might wish
to check for; others warn about constructions that are
necessary or hard to avoid in some cases, and there is no
simple way to modify the code to suppress the warning.

-W Print extra warning messages for these events:
...

That's from the old gcc 3.3.2 manpage. Apparently -W is deprecated
now. The 4.4.0 manpage says the following:

-Wextra
This enables some extra warning flags that are not enabled by
-Wall. (This option used to be called -W. The older name is
still supported, but the newer name is more descriptive.)
...

So, if you have a newer version of gcc, you can search for -Wextra to
see the full list of warnings it enables.

--
Jason Blevins
Ph.D. Candidate, Department of Economics, Duke University
http://jblevins.org/

Erik Toussaint

unread,
Apr 29, 2009, 3:17:32 PM4/29/09
to
Jason Blevins wrote:
[...]

Thanks, that was quick.
Erik.

Gordon Sande

unread,
Apr 29, 2009, 4:01:34 PM4/29/09
to
On 2009-04-29 16:00:39 -0300, Jason Blevins <jrbl...@sdf.lonestar.org> said:

> On Apr 29, 2009, at 2:45 PM, Erik Toussaint wrote:
>> on the 'Gettting started with gfortran' page at the gcc wiki,
>> http://gcc.gnu.org/wiki/GFortranGettingStarted
>> in the 'Standard conformance and other warnings' section, the
>> following commandline is recommended:
>>
>> gfortran -std=f95 -W -Wall -pedantic mycode.f
>>
>> I can't find a description of the -W switch in the gfortran
>> documentation ( http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gfortran/ ).
>> Does anyone here know what exactly it means/does?
>
> gfortran is part of gcc, the GNU C compiler, and shares many

At some point the meaning of gcc was changed to GNU Compiler Collection
if I recall the bolierplate. GCC became the name for all of the compilers
that share the same middle and backends. But gcc was still the name for the
C compiler in the collection. Yes, I am confused as well.

> options with gcc itself (it seems they share a common frontend).

Surely you meant they are differing frontends to a common middle and backend.

Jason Blevins

unread,
Apr 29, 2009, 5:19:26 PM4/29/09
to
On Apr 29, 2009, at 4:01 PM, Gordon Sande wrote:
> On 2009-04-29 16:00:39 -0300, Jason Blevins <jrbl...@sdf.lonestar.org> said:
>> gfortran is part of gcc, the GNU C compiler, and shares many
>
> At some point the meaning of gcc was changed to GNU Compiler Collection
> if I recall the bolierplate. GCC became the name for all of the compilers
> that share the same middle and backends. But gcc was still the name for the
> C compiler in the collection. Yes, I am confused as well.
>
>> options with gcc itself (it seems they share a common frontend).
>
> Surely you meant they are differing frontends to a common middle and backend.

I only meant it in the lay sense, that they share a uniform command-line
interface with a lot of common switches. I see now that the front,
middle, and back end are actually well-defined components of a
compiler so you're absolutely right.

Craig Powers

unread,
Apr 29, 2009, 7:58:03 PM4/29/09
to
Gordon Sande wrote:
>
> Surely you meant they are differing frontends to a common middle and
> backend.

Differing front-ends, certainly, but I think there's a common
front-front-end that does the basic option handling, where the actual
fortran front-end is not "gfortran" but instead "f951".

0 new messages