7.3 Non-Fortran Main Program
• _gfortran_set_args: | Save command-line arguments | |
• _gfortran_set_options: | Set library option flags | |
• _gfortran_set_convert: | Set endian conversion | |
• _gfortran_set_record_marker: | Set length of record markers | |
• _gfortran_set_fpe: | Set when a Floating Point Exception should be raised | |
• _gfortran_set_max_subrecord_length: | Set subrecord length |
Even if you are doing mixed-language programming, it is very likely that you do not need to know or use the information in this section. Since it is about the internal structure of GNU Fortran, it may also change in GCC minor releases.
When you compile a PROGRAM
with GNU Fortran, a function with the name main
(in the symbol table of the object file) is generated, which initializes the libgfortran library and then calls the actual program which uses the name MAIN__
, for historic reasons. If you link GNU Fortran compiled procedures to, e.g., a C or C++ program or to a Fortran program compiled by a different compiler, the libgfortran library is not initialized and thus a few intrinsic procedures do not work properly, e.g. those for obtaining the command-line arguments.
Therefore, if your PROGRAM
is not compiled with GNU Fortran and the GNU Fortran compiled procedures require intrinsics relying on the library initialization, you need to initialize the library yourself. Using the default options, gfortran calls _gfortran_set_args
and _gfortran_set_options
. The initialization of the former is needed if the called procedures access the command line (and for backtracing); the latter sets some flags based on the standard chosen or to enable backtracing. In typical programs, it is not necessary to call any initialization function.
If your PROGRAM
is compiled with GNU Fortran, you shall not call any of the following functions. The libgfortran initialization functions are shown in C syntax but using C bindings they are also accessible from Fortran.
Next: Naming and argument-passing conventions, Previous: GNU Fortran Compiler Directives, Up: Mixed-Language Programming [Contents][Index]
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gfortran/Non_002dFortran-Main-Program.html