public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fortran: Add more documentation for mixed-language programming
@ 2021-11-05 21:12 Sandra Loosemore
  2021-11-06  9:02 ` Paul Richard Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: Sandra Loosemore @ 2021-11-05 21:12 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

I was recently pinged about PR35276.  It's an old issue, but a couple of 
the concerns raised there haven't been fixed yet, so I've checked in 
this patch to fill in the gaps.

-Sandra

[-- Attachment #2: pr35276.patch --]
[-- Type: text/x-patch, Size: 2001 bytes --]

commit b8bf685ed44dba9bd4bbd600bc8bc2be0a2abb1b
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Fri Nov 5 14:01:03 2021 -0700

    Fortran: Add more documentation for mixed-language programming [PR35276]
    
    2021-11-05  Sandra Loosemore  <sandra@codesourcery.com>
    
    	PR fortran/35276
    
    	gcc/fortran/
    	* gfortran.texi (Mixed-Language Programming): Talk about C++,
    	and how to link.

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index f3a961e..3264709 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2718,11 +2718,23 @@ reading from the position marked previously.
 * Naming and argument-passing conventions::
 @end menu
 
-This chapter is about mixed-language interoperability, but also applies
-if one links Fortran code compiled by different compilers.  In most cases,
-use of the C Binding features of the Fortran 2003 standard is sufficient,
-and their use is highly recommended.
-
+This chapter is about mixed-language interoperability, but also
+applies if you link Fortran code compiled by different compilers.  In
+most cases, use of the C Binding features of the Fortran 2003 and
+later standards is sufficient.
+
+For example, it is possible to mix Fortran code with C++ code as well
+as C, if you declare the interface functions as @code{extern "C"} on
+the C++ side and @code{BIND(C)} on the Fortran side, and follow the
+rules for interoperability with C.  Note that you cannot manipulate
+C++ class objects in Fortran or vice versa except as opaque pointers.
+
+You can use the @command{gfortran} command to link both Fortran and
+non-Fortran code into the same program, or you can use @command{gcc}
+or @command{g++} if you also add an explicit @option{-lgfortran} option
+to link with the Fortran library.  If your main program is written in
+C or some other language instead of Fortran, see
+@ref{Non-Fortran Main Program}, below.
 
 @node Interoperability with C
 @section Interoperability with C

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [committed] Fortran: Add more documentation for mixed-language programming
  2021-11-05 21:12 [committed] Fortran: Add more documentation for mixed-language programming Sandra Loosemore
@ 2021-11-06  9:02 ` Paul Richard Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2021-11-06  9:02 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: fortran, gcc-patches

Hi Sandra,

Looks good to me.

Thanks

Paul


On Fri, 5 Nov 2021 at 21:13, Sandra Loosemore <sandra@codesourcery.com>
wrote:

> I was recently pinged about PR35276.  It's an old issue, but a couple of
> the concerns raised there haven't been fixed yet, so I've checked in
> this patch to fill in the gaps.
>
> -Sandra
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-06  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 21:12 [committed] Fortran: Add more documentation for mixed-language programming Sandra Loosemore
2021-11-06  9:02 ` Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).