* f77/cpp bug?
@ 1995-08-09 4:00 Mark Hays
1995-08-10 4:00 ` Dan Pop
0 siblings, 1 reply; 5+ messages in thread
From: Mark Hays @ 1995-08-09 4:00 UTC (permalink / raw)
Hello,
I think I may have found a bug in the DEC f77 compiler.
From the f77(1) manpage:
"Arguments with the suffix .F are interpreted as FORTRAN source pro-
grams which must be processed by the C preprocessor (cpp(1)) before
being compiled."
From the cpp(1) manpage:
"The cpp preprocessor accepts C++-style end of line comments (//). This
means that everything following the two slashes (//) to the end of the line
in which they appear is considered as a comment."
Since there doesn't seem to be a way to turn off the
removal of C++ comments, may I assume that one should
never concatenate strings (with //) in DEC f77 .F
files?
I have a script that gets around this to a certain
extent -- combo of /usr/lib/cpp and sed; however, the
line numbers in the compiler errors are all screwed
up since I'm compiling the preprocessed version, so
it is far from an ideal workaround...
Has anyone else noticed this and found a better
solution?
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: f77/cpp bug?
1995-08-09 4:00 f77/cpp bug? Mark Hays
@ 1995-08-10 4:00 ` Dan Pop
1995-08-10 4:00 ` Mark Hays
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dan Pop @ 1995-08-10 4:00 UTC (permalink / raw)
In <409n4u$3j4@cortaro.math.arizona.edu> hays@math.arizona.edu (Mark Hays) writes:
>I think I may have found a bug in the DEC f77 compiler.
>
>From the f77(1) manpage:
> "Arguments with the suffix .F are interpreted as FORTRAN source pro-
> grams which must be processed by the C preprocessor (cpp(1)) before
> being compiled."
>
>From the cpp(1) manpage:
> "The cpp preprocessor accepts C++-style end of line comments (//). This
> means that everything following the two slashes (//) to the end of the line
> in which they appear is considered as a comment."
>
>Since there doesn't seem to be a way to turn off the
>removal of C++ comments, may I assume that one should
>never concatenate strings (with //) in DEC f77 .F
>files?
Have you actually tried to compile a .F file which contains // with f77
and had problems? I have only f90 installed and I never had this problem
because the compiler does the right thing: it invokes cpp with whatever
magic options are required to disable the C++ comments:
ues5:~/tmp 499> cat foo.F
print *, "foo" // "bar"
end
ues5:~/tmp 500> f90 foo.F
ues5:~/tmp 501> ./a.out
foobar
I complained to DEC about the (broken, IMHO) _default_ behaviour of cpp
WRT C++ style comments (it breaks utilities like xrdb if you have URL's
in your .Xdefaults), but their answer was:
Here is the feedback we received from Engineering concerning the "cpp"
behaviour which makes you feel unhappy.
After careful reflection, they decided to leave the "C++ comment style"
functionnality of "cpp" unchanged.
Dan
--
Dan Pop
CERN, CN Division
Email: Dan.Pop@mail.cern.ch
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: f77/cpp bug?
1995-08-10 4:00 ` Dan Pop
@ 1995-08-10 4:00 ` Mark Hays
1995-08-11 4:00 ` John Hascall
1995-08-11 4:00 ` Craig Neth USG
2 siblings, 0 replies; 5+ messages in thread
From: Mark Hays @ 1995-08-10 4:00 UTC (permalink / raw)
Hi Dan,
In article <danpop.808014191@rscernix>, Dan Pop <Dan.Pop@mail.cern.ch> wrote:
>[my jabber deleted]
>Have you actually tried to compile a .F file which contains // with f77
>and had problems? I have only f90 installed and I never had this problem
>because the compiler does the right thing: it invokes cpp with whatever
>magic options are required to disable the C++ comments:
>
> ues5:~/tmp 499> cat foo.F
> print *, "foo" // "bar"
> end
> ues5:~/tmp 500> f90 foo.F
> ues5:~/tmp 501> ./a.out
> foobar
>
Yes, you are right -- after a closer examination, I find
that DEC f77 actually invokes /usr/lib/cpp89, which only
removes C++ comments if you give it the right flags! The
problem is that the makefiles I have for this particular
piece of software call /usr/lib/cpp directly. It never
occurred to me that there might be *two* cpp's running
around. Got a little ahead of myself on this one -- sorry.
>I complained to DEC about the (broken, IMHO) _default_ behaviour of cpp
>WRT C++ style comments (it breaks utilities like xrdb if you have URL's
>in your .Xdefaults), but their answer was:
Ouch. Yes, that is bad.
> Here is the feedback we received from Engineering concerning the "cpp"
> behaviour which makes you feel unhappy.
>
> After careful reflection, they decided to leave the "C++ comment style"
> functionnality of "cpp" unchanged.
>
That's too bad. Most vendor's seem to do it like cpp89 --
you can enable this feature if you want to. I agree with
you: it isn't such a good idea to have this on by default,
especially with no way to turn it off.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: f77/cpp bug?
1995-08-10 4:00 ` Dan Pop
1995-08-10 4:00 ` Mark Hays
@ 1995-08-11 4:00 ` John Hascall
1995-08-11 4:00 ` Craig Neth USG
2 siblings, 0 replies; 5+ messages in thread
From: John Hascall @ 1995-08-11 4:00 UTC (permalink / raw)
Dan Pop <Dan.Pop@mail.cern.ch> wrote:
}hays@math.arizona.edu (Mark Hays) writes:
}>I think I may have found a bug in the DEC f77 compiler.
}>Since there doesn't seem to be a way to turn off the
}>removal of C++ comments, may I assume that one should
}>never concatenate strings (with //) in DEC f77 .F
}>files?
}Have you actually tried to compile a .F file which contains // with f77
}and had problems? I have only f90 installed and I never had this problem
}because the compiler does the right thing: it invokes cpp with whatever
}magic options are required to disable the C++ comments:
}
} ues5:~/tmp 499> cat foo.F
} print *, "foo" // "bar"
} end
} ues5:~/tmp 500> f90 foo.F
} ues5:~/tmp 501> ./a.out
} foobar
Oddly enough, the flags which trigger this seem to be either
-D__LANGUAGE_FORTRAN or -DLANGUAGE_FORTRAN
John
--
John Hascall ``An ill-chosen word is the fool's messenger.''
Moderator, comp.unix.wizards
Systems Software Engineer, ISU Comp Center + Ames, IA 50011 + 515/294-9551
<a href="http://www.cc.iastate.edu/staff/systems/john/">My Homepage</a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: f77/cpp bug?
1995-08-10 4:00 ` Dan Pop
1995-08-10 4:00 ` Mark Hays
1995-08-11 4:00 ` John Hascall
@ 1995-08-11 4:00 ` Craig Neth USG
2 siblings, 0 replies; 5+ messages in thread
From: Craig Neth USG @ 1995-08-11 4:00 UTC (permalink / raw)
In article <danpop.808014191@rscernix>, Dan.Pop@mail.cern.ch (Dan Pop) writes:
>I complained to DEC about the (broken, IMHO) _default_ behaviour of cpp
>WRT C++ style comments (it breaks utilities like xrdb if you have URL's
>in your .Xdefaults), but their answer was:
>
> Here is the feedback we received from Engineering concerning the "cpp"
> behaviour which makes you feel unhappy.
>
> After careful reflection, they decided to leave the "C++ comment style"
> functionnality of "cpp" unchanged.
>
>Dan
-DFORTRAN or -D_FORTRAN will turn off the C++ comment processing in cpp.
Craig
--------------------------------------------------------------------------------
Craig Neth ! neth@zk3.dec.com
Digital Equipment Corporation !
110 Spit Brook Road ZKO3-3/Y25 !
Nashua, NH 03062 ! Opinions expressed herein are my own.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1995-08-11 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-08-09 4:00 f77/cpp bug? Mark Hays
1995-08-10 4:00 ` Dan Pop
1995-08-10 4:00 ` Mark Hays
1995-08-11 4:00 ` John Hascall
1995-08-11 4:00 ` Craig Neth USG
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox