public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4959] Fortran: Add more documentation for mixed-language programming [PR35276]
Date: Fri,  5 Nov 2021 21:08:49 +0000 (GMT)	[thread overview]
Message-ID: <20211105210849.323DB385840A@sourceware.org> (raw)

https://gcc.gnu.org/g:452a0afbace650d7c0f2811e2b47e62dcd18e1fd

commit r12-4959-g452a0afbace650d7c0f2811e2b47e62dcd18e1fd
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:
---
 gcc/fortran/gfortran.texi | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index f3a961e4c1b..326470964b0 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


                 reply	other threads:[~2021-11-05 21:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105210849.323DB385840A@sourceware.org \
    --to=sandra@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).