diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2021-11-05 14:01:03 -0700 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2021-11-05 14:08:36 -0700 |
commit | 452a0afbace650d7c0f2811e2b47e62dcd18e1fd (patch) | |
tree | bd8ebc015257904abfd2c36bdfc09a51bf7c766f /gcc | |
parent | 8f4860f956871c3fd77ed60567d707490104f370 (diff) | |
download | gcc-452a0afbace650d7c0f2811e2b47e62dcd18e1fd.zip gcc-452a0afbace650d7c0f2811e2b47e62dcd18e1fd.tar.gz gcc-452a0afbace650d7c0f2811e2b47e62dcd18e1fd.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/gfortran.texi | 22 |
1 files changed, 17 insertions, 5 deletions
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 |