Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Name mangling
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Fortran === Name mangling is also necessary in [[Fortran]] compilers, originally because the language is [[case insensitive]]. Further mangling requirements were imposed later in the evolution of the language because of the addition of [[Module (programming)|modules]] and other features in the Fortran 90 standard. The case mangling, especially, is a common issue that must be dealt with to call Fortran libraries, such as [[LAPACK]], from other languages, such as [[C (programming language)|C]]. Because of the case insensitivity, the name of a subroutine or function {{code|FOO}} must be converted to a standardized case and format by the compiler so that it will be linked in the same way regardless of case. Different compilers have implemented this in various ways, and no standardization has occurred. The [[IBM AIX|AIX]] and [[HP-UX]] Fortran compilers convert all identifiers to lower case {{code|foo}}, while the [[Cray]] and [[Unicos]] Fortran compilers converted identifiers to all upper case {{code|FOO}}. The [[GNU]] [[GNU Compiler Collection|g77]] compiler converts identifiers to lower case plus an underscore {{code|foo_}}, except that identifiers already containing an underscore {{code|FOO_BAR}} have two underscores appended {{code|foo_bar__}}, following a convention established by [[f2c]]. Many other compilers, including [[Silicon Graphics]]'s (SGI) [[IRIX]] compilers, [[GNU Fortran]], and [[Intel]]'s Fortran compiler (except on Microsoft Windows), convert all identifiers to lower case plus an underscore ({{code|foo_}} and {{code|foo_bar_}}, respectively). On Microsoft Windows, the Intel Fortran compiler defaults to uppercase without an underscore.<ref>{{cite web|title=Summary of Mixed-Language Issues|url=https://software.intel.com/en-us/node/525345|website=User and Reference Guide for the Intel Fortran Compiler 15.0|publisher=Intel Corporation|access-date=17 November 2014}}</ref> Identifiers in Fortran 90 modules must be further mangled, because the same procedure name may occur in different modules. Since the Fortran 2003 Standard requires that module procedure names not conflict with other external symbols,<ref>{{Cite web|url=https://software.intel.com/en-us/node/510637|title = Documentation Library}}</ref> compilers tend to use the module name and the procedure name, with a distinct marker in between. For example: <syntaxhighlight lang="fortran"> module m contains integer function five() five = 5 end function five end module m </syntaxhighlight> In this module, the name of the function will be mangled as {{code|__m_MOD_five}} (e.g., GNU Fortran), {{code|m_MP_five_}} (e.g., Intel's ifort), {{code|m.five_}} (e.g., Oracle's sun95), etc. Since Fortran does not allow overloading the name of a procedure, but uses [[Fortran 95 language features#Overloading and generic interfaces|generic interface blocks]] and generic type-bound procedures instead, the mangled names do not need to incorporate clues about the arguments. The Fortran 2003 BIND option overrides any name mangling done by the compiler, as shown [[#C name decoration in Microsoft Windows|above]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)