blob: 990dc59b6078316bc980f3ae3866e2ea5c6627f1 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1999-2014 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
"GNU Free Documentation License".
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development. -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>The GNU Fortran Compiler: GNU Fortran Compiler Directives</title>
<meta name="description" content="The GNU Fortran Compiler: GNU Fortran Compiler Directives">
<meta name="keywords" content="The GNU Fortran Compiler: GNU Fortran Compiler Directives">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Mixed_002dLanguage-Programming.html#Mixed_002dLanguage-Programming" rel="up" title="Mixed-Language Programming">
<link href="Non_002dFortran-Main-Program.html#Non_002dFortran-Main-Program" rel="next" title="Non-Fortran Main Program">
<link href="Further-Interoperability-of-Fortran-with-C.html#Further-Interoperability-of-Fortran-with-C" rel="prev" title="Further Interoperability of Fortran with C">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="GNU-Fortran-Compiler-Directives"></a>
<div class="header">
<p>
Next: <a href="Non_002dFortran-Main-Program.html#Non_002dFortran-Main-Program" accesskey="n" rel="next">Non-Fortran Main Program</a>, Previous: <a href="Interoperability-with-C.html#Interoperability-with-C" accesskey="p" rel="prev">Interoperability with C</a>, Up: <a href="Mixed_002dLanguage-Programming.html#Mixed_002dLanguage-Programming" accesskey="u" rel="up">Mixed-Language Programming</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="GNU-Fortran-Compiler-Directives-1"></a>
<h3 class="section">7.2 GNU Fortran Compiler Directives</h3>
<p>The Fortran standard describes how a conforming program shall
behave; however, the exact implementation is not standardized. In order
to allow the user to choose specific implementation details, compiler
directives can be used to set attributes of variables and procedures
which are not part of the standard. Whether a given attribute is
supported and its exact effects depend on both the operating system and
on the processor; see
<a href="http://gcc.gnu.org/onlinedocs/gcc/index.html#Top">C Extensions</a> in <cite>Using the GNU Compiler Collection (GCC)</cite>
for details.
</p>
<p>For procedures and procedure pointers, the following attributes can
be used to change the calling convention:
</p>
<ul>
<li> <code>CDECL</code> &ndash; standard C calling convention
</li><li> <code>STDCALL</code> &ndash; convention where the called procedure pops the stack
</li><li> <code>FASTCALL</code> &ndash; part of the arguments are passed via registers
instead using the stack
</li></ul>
<p>Besides changing the calling convention, the attributes also influence
the decoration of the symbol name, e.g., by a leading underscore or by
a trailing at-sign followed by the number of bytes on the stack. When
assigning a procedure to a procedure pointer, both should use the same
calling convention.
</p>
<p>On some systems, procedures and global variables (module variables and
<code>COMMON</code> blocks) need special handling to be accessible when they
are in a shared library. The following attributes are available:
</p>
<ul>
<li> <code>DLLEXPORT</code> &ndash; provide a global pointer to a pointer in the DLL
</li><li> <code>DLLIMPORT</code> &ndash; reference the function or variable using a global pointer
</li></ul>
<p>For dummy arguments, the <code>NO_ARG_CHECK</code> attribute can be used; in
other compilers, it is also known as <code>IGNORE_TKR</code>. For dummy arguments
with this attribute actual arguments of any type and kind (similar to
<code>TYPE(*)</code>), scalars and arrays of any rank (no equivalent
in Fortran standard) are accepted. As with <code>TYPE(*)</code>, the argument
is unlimited polymorphic and no type information is available.
Additionally, the argument may only be passed to dummy arguments
with the <code>NO_ARG_CHECK</code> attribute and as argument to the
<code>PRESENT</code> intrinsic function and to <code>C_LOC</code> of the
<code>ISO_C_BINDING</code> module.
</p>
<p>Variables with <code>NO_ARG_CHECK</code> attribute shall be of assumed-type
(<code>TYPE(*)</code>; recommended) or of type <code>INTEGER</code>, <code>LOGICAL</code>,
<code>REAL</code> or <code>COMPLEX</code>. They shall not have the <code>ALLOCATE</code>,
<code>CODIMENSION</code>, <code>INTENT(OUT)</code>, <code>POINTER</code> or <code>VALUE</code>
attribute; furthermore, they shall be either scalar or of assumed-size
(<code>dimension(*)</code>). As <code>TYPE(*)</code>, the <code>NO_ARG_CHECK</code> attribute
requires an explicit interface.
</p>
<ul>
<li> <code>NO_ARG_CHECK</code> &ndash; disable the type, kind and rank checking
</li></ul>
<p>The attributes are specified using the syntax
</p>
<p><code>!GCC$ ATTRIBUTES</code> <var>attribute-list</var> <code>::</code> <var>variable-list</var>
</p>
<p>where in free-form source code only whitespace is allowed before <code>!GCC$</code>
and in fixed-form source code <code>!GCC$</code>, <code>cGCC$</code> or <code>*GCC$</code> shall
start in the first column.
</p>
<p>For procedures, the compiler directives shall be placed into the body
of the procedure; for variables and procedure pointers, they shall be in
the same declaration part as the variable or procedure pointer.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Non_002dFortran-Main-Program.html#Non_002dFortran-Main-Program" accesskey="n" rel="next">Non-Fortran Main Program</a>, Previous: <a href="Interoperability-with-C.html#Interoperability-with-C" accesskey="p" rel="prev">Interoperability with C</a>, Up: <a href="Mixed_002dLanguage-Programming.html#Mixed_002dLanguage-Programming" accesskey="u" rel="up">Mixed-Language Programming</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>