1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Ada95 - Interfacing Pragmas</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-B.html">Previous</A> <A HREF="RM-B-2.html">Next</A></P>
<HR>
<H1> B.1 Interfacing Pragmas</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Import is used to import an entity defined in a foreign language into
an Ada program, thus allowing a foreign-language subprogram to be called
from Ada, or a foreign-language variable to be accessed from Ada. In
contrast, a <FONT FACE="Arial, Helvetica">pragma</FONT> Export is used
to export an Ada entity to a foreign language, thus allowing an Ada subprogram
to be called from a foreign language, or an Ada object to be accessed
from a foreign language. The <FONT FACE="Arial, Helvetica">pragma</FONT>s
Import and Export are intended primarily for objects and subprograms,
although implementations are allowed to support other entities.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Convention is used to specify that an Ada entity should use the conventions
of another language. It is intended primarily for types and ``callback''
subprograms. For example, ``<B>pragma</B> Convention(Fortran, Matrix);''
implies that Matrix should be represented according to the conventions
of the supported Fortran implementation, namely column-major order.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Linker_Options is used to specify the system linker parameters needed
when a given compilation unit is included in a partition.</DIV>
<H4 ALIGN=CENTER>Syntax</H4>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="SyntaxIndented" Style="margin-bottom: 0.2em"><A NAME="I6012"></A><A NAME="I6013"></A><A NAME="I6014"></A><A NAME="I6015"></A><A NAME="I6016"></A><A NAME="I6017"></A><A NAME="I6018"></A><A NAME="I6019"></A>An
<I>interfacing pragma</I> is a representation <FONT FACE="Arial, Helvetica">pragma</FONT>
that is one of the <FONT FACE="Arial, Helvetica">pragma</FONT>s Import,
Export, or Convention. Their forms, together with that of the related
<FONT FACE="Arial, Helvetica">pragma</FONT> Linker_Options, are as follows:
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6020"></A>Import(<BR>
[Convention =>] <I>convention_</I><A NAME="I6021"></A><FONT FACE="Arial, Helvetica">identifier</FONT>,
[Entity =>] <A NAME="I6022"></A><FONT FACE="Arial, Helvetica">local_name</FONT><BR>
[, [External_Name =>] <I>string_</I><A NAME="I6023"></A><FONT FACE="Arial, Helvetica">expression</FONT>]
[, [Link_Name =>] <I>string_</I><A NAME="I6024"></A><FONT FACE="Arial, Helvetica">expression</FONT>]);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6025"></A>Export(<BR>
[Convention =>] <I>convention_</I><A NAME="I6026"></A><FONT FACE="Arial, Helvetica">identifier</FONT>,
[Entity =>] <A NAME="I6027"></A><FONT FACE="Arial, Helvetica">local_name</FONT><BR>
[, [External_Name =>] <I>string_</I><A NAME="I6028"></A><FONT FACE="Arial, Helvetica">expression</FONT>]
[, [Link_Name =>] <I>string_</I><A NAME="I6029"></A><FONT FACE="Arial, Helvetica">expression</FONT>]);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6030"></A>Convention([Convention
=>] <I>convention_</I><A NAME="I6031"></A><FONT FACE="Arial, Helvetica">identifier</FONT>,[Entity
=>] <A NAME="I6032"></A><FONT FACE="Arial, Helvetica">local_name</FONT>);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="SyntaxIndented"> <B>pragma</B> <A NAME="I6033"></A>Linker_Options(<I>string_</I><A NAME="I6034"></A><FONT FACE="Arial, Helvetica">expression</FONT>);</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="SyntaxIndented">A <FONT FACE="Arial, Helvetica">pragma</FONT>
Linker_Options is allowed only at the place of a <FONT FACE="Arial, Helvetica">declarative_item</FONT>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.1/1</FONT></DIV>
<DIV Class="SyntaxIndented">For <FONT FACE="Arial, Helvetica">pragma</FONT>s
Import and Export, the argument for Link_Name shall not be given without
the <FONT FACE="Arial, Helvetica">pragma_argument_identifier</FONT> unless
the argument for External_Name is given. </DIV>
<H4 ALIGN=CENTER>Name Resolution Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6035"></A>The expected type for a <I>string_</I><A NAME="I6036"></A><FONT FACE="Arial, Helvetica">expression</FONT>
in an interfacing pragma or in pragma Linker_Options is String. </DIV>
<H4 ALIGN=CENTER>Legality Rules</H4>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6037"></A>The <I>convention_</I><FONT FACE="Arial, Helvetica">identifier</FONT>
of an interfacing pragma shall be the name of a <I>convention</I>. The
convention names are implementation defined, except for certain language-defined
ones, such as Ada and Intrinsic, as explained in <A HREF="RM-6-3-1.html">6.3.1</A>,
``<A HREF="RM-6-3-1.html">Conformance Rules</A>''. Additional convention
names generally represent the calling conventions of foreign languages,
language implementations, or specific run-time models. <A NAME="I6038"></A>The
convention of a callable entity is its <I>calling convention</I>. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <A NAME="I6039"></A>If
<I>L</I> is a <I>convention_</I><FONT FACE="Arial, Helvetica">identifier</FONT>
for a language, then a type T is said to be <I>compatible with convention
L</I>, (alternatively, is said to be an <I>L-compatible type</I>) if
any of the following conditions are met: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>T is declared in a language interface package corresponding
to <I>L</I> and is defined to be <I>L</I>-compatible (see <A HREF="RM-B-3.html">B.3</A>,
<A HREF="RM-B-3-1.html">B.3.1</A>, <A HREF="RM-B-3-2.html">B.3.2</A>,
<A HREF="RM-B-4.html">B.4</A>, <A HREF="RM-B-5.html">B.5</A>),</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<UL Class="Bulleted" Style="margin-bottom: 0.3em"><LI TYPE=DISC><A NAME="I6040"></A>Convention <I>L</I> has been specified
for T in a <FONT FACE="Arial, Helvetica">pragma</FONT> Convention, and
T is <I>eligible for convention L</I>; that is: </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>T is an array type with either an unconstrained or statically-constrained
first subtype, and its component type is <I>L</I>-compatible,</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>T is a record type that has no discriminants and that only
has components with statically-constrained subtypes, and each component
type is <I>L</I>-compatible,</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>T is an access-to-object type, and its designated type
is <I>L</I>-compatible,</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<UL Class="NestedBulleted"><LI TYPE=DISC>T is an access-to-subprogram type, and its designated profile's
parameter and result types are all <I>L</I>-compatible. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>T is derived from an <I>L</I>-compatible type,</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>The implementation permits T as an <I>L</I>-compatible
type. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal"> If <FONT FACE="Arial, Helvetica">pragma</FONT>
Convention applies to a type, then the type shall either be compatible
with or eligible for the convention specified in the pragma. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Normal"> A <FONT FACE="Arial, Helvetica">pragma</FONT>
Import shall be the completion of a declaration. <A NAME="I6041"></A>Notwithstanding
any rule to the contrary, a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import may serve as the completion of any kind of (explicit) declaration
if supported by an implementation for that kind of declaration. If a
completion is a <FONT FACE="Arial, Helvetica">pragma</FONT> Import, then
it shall appear in the same <FONT FACE="Arial, Helvetica">declarative_part</FONT>,
<FONT FACE="Arial, Helvetica">package_specification</FONT>, <FONT FACE="Arial, Helvetica">task_definition</FONT>
or <FONT FACE="Arial, Helvetica">protected_definition</FONT> as the declaration.
For a library unit, it shall appear in the same <FONT FACE="Arial, Helvetica">compilation</FONT>,
before any subsequent <FONT FACE="Arial, Helvetica">compilation_unit</FONT>s
other than <FONT FACE="Arial, Helvetica">pragma</FONT>s. If the <FONT FACE="Arial, Helvetica">local_name</FONT>
denotes more than one entity, then the <FONT FACE="Arial, Helvetica">pragma</FONT>
Import is the completion of all of them. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6042"></A> <A NAME="I6043"></A>An entity
specified as the Entity argument to a <FONT FACE="Arial, Helvetica">pragma</FONT>
Import (or <FONT FACE="Arial, Helvetica">pragma</FONT> Export) is said
to be <I>imported</I> (respectively, <I>exported</I>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal"> The declaration of an imported object shall not
include an explicit initialization expression. Default initializations
are not performed. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal"> The type of an imported or exported object shall
be compatible with the convention specified in the corresponding <FONT FACE="Arial, Helvetica">pragma</FONT>.
</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Normal"> For an imported or exported subprogram, the result
and parameter types shall each be compatible with the convention specified
in the corresponding pragma.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal"> The external name and link name <I>string</I>_<FONT FACE="Arial, Helvetica">expression</FONT>s
of a <FONT FACE="Arial, Helvetica">pragma</FONT> Import or Export, and
the <I>string</I>_<FONT FACE="Arial, Helvetica">expression</FONT> of
a <FONT FACE="Arial, Helvetica">pragma</FONT> Linker_Options, shall be
static. </DIV>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6044"></A><A NAME="I6045"></A><A NAME="I6046"></A><A NAME="I6047"></A><A NAME="I6048"></A><A NAME="I6049"></A><A NAME="I6050"></A><A NAME="I6051"></A>Import,
Export, and Convention <FONT FACE="Arial, Helvetica">pragma</FONT>s are
representation pragmas that specify the <I>convention</I> aspect of representation.
<A NAME="I6052"></A><A NAME="I6053"></A><A NAME="I6054"></A><A NAME="I6055"></A>In
addition, Import and Export <FONT FACE="Arial, Helvetica">pragma</FONT>s
specify the <I>imported</I> and <I>exported</I> aspects of representation,
respectively.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6056"></A><A NAME="I6057"></A><A NAME="I6058"></A><A NAME="I6059"></A><A NAME="I6060"></A><A NAME="I6061"></A>An
interfacing pragma is a program unit pragma when applied to a program
unit (see <A HREF="RM-10-1-5.html">10.1.5</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> An interfacing
pragma defines the convention of the entity denoted by the <FONT FACE="Arial, Helvetica">local_name</FONT>.
The convention represents the calling convention or representation convention
of the entity. For an access-to-subprogram type, it represents the calling
convention of designated subprograms. In addition: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A <FONT FACE="Arial, Helvetica">pragma</FONT> Import specifies
that the entity is defined externally (that is, outside the Ada program).</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A <FONT FACE="Arial, Helvetica">pragma</FONT> Export specifies
that the entity is used externally.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>A <FONT FACE="Arial, Helvetica">pragma</FONT> Import or
Export optionally specifies an entity's external name, link name, or
both. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6062"></A>An <I>external name</I> is
a string value for the name used by a foreign language program either
for an entity that an Ada program imports, or for referring to an entity
that an Ada program exports.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6063"></A>A <I>link name</I> is a string
value for the name of an exported or imported entity, based on the conventions
of the foreign language's compiler in interfacing with the system's linker
tool.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Normal"> The meaning of link names is implementation defined.
If neither a link name nor the Address attribute of an imported or exported
entity is specified, then a link name is chosen in an implementation-defined
manner, based on the external name if one is specified. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Normal"> Pragma Linker_Options has the effect of passing
its string argument as a parameter to the system linker (if one exists),
if the immediately enclosing compilation unit is included in the partition
being linked. The interpretation of the string argument, and the way
in which the string arguments from multiple Linker_Options pragmas are
combined, is implementation defined. </DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Normal"> <A NAME="I6064"></A><A NAME="I6065"></A>Notwithstanding
what this International Standard says elsewhere, the elaboration of a
declaration denoted by the <FONT FACE="Arial, Helvetica">local_name</FONT>
of a <FONT FACE="Arial, Helvetica">pragma</FONT> Import does not create
the entity. Such an elaboration has no other effect than to allow the
defining name to denote the external entity. </DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Normal"> If an implementation supports pragma Export to
a given language, then it should also allow the main subprogram to be
written in that language. It should support some mechanism for invoking
the elaboration of the Ada library units included in the system, and
for invoking the finalization of the environment task. On typical systems,
the recommended mechanism is to provide two subprograms whose link names
are "adainit" and "adafinal". Adainit should contain
the elaboration code for library units. Adafinal should contain the finalization
code. These subprograms should have no effect the second and subsequent
time they are called. <A NAME="I6066"></A><A NAME="I6067"></A><A NAME="I6068"></A><A NAME="I6069"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Normal"> Automatic elaboration of preelaborated packages
should be provided when <FONT FACE="Arial, Helvetica">pragma</FONT> Export
is supported.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Normal"> For each supported convention <I>L</I> other
than Intrinsic, an implementation should support Import and Export <FONT FACE="Arial, Helvetica">pragma</FONT>s
for objects of <I>L</I>-compatible types and for subprograms, and <FONT FACE="Arial, Helvetica">pragma</FONT>
Convention for <I>L</I>-eligible types and for subprograms, presuming
the other language has corresponding features. <FONT FACE="Arial, Helvetica">Pragma</FONT>
Convention need not be supported for scalar types. </DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>1 Implementations may place
restrictions on interfacing pragmas; for example, requiring each exported
entity to be declared at the library level. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>2 A <FONT FACE="Arial, Helvetica">pragma</FONT>
Import specifies the conventions for accessing external entities. It
is possible that the actual entity is written in assembly language, but
reflects the conventions of a particular language. For example, <B>pragma</B>
Import(Ada, ...) can be used to interface to an assembly language routine
that obeys the Ada compiler's calling conventions.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>3 To obtain ``call-back''
to an Ada subprogram from a foreign language environment, <B>pragma</B>
Convention should be specified both for the access-to-subprogram type
and the specific subprogram(s) to which 'Access is applied.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>4 It is illegal to specify
more than one of Import, Export, or Convention for a given entity.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>5 The <FONT FACE="Arial, Helvetica">local_name</FONT>
in an interfacing pragma can denote more than one entity in the case
of overloading. Such a <FONT FACE="Arial, Helvetica">pragma</FONT> applies
to all of the denoted entities.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>6 See also <A HREF="RM-13-8.html">13.8</A>,
``<A HREF="RM-13-8.html">Machine Code Insertions</A>''. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>7 If both External_Name and
Link_Name are specified for an Import or Export pragma, then the External_Name
is ignored.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>8 An interfacing pragma might
result in an effect that violates Ada semantics. </FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Example of interfacing
pragmas:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B> Fortran_Library <B>is</B><BR>
<B>function</B> Sqrt (X : Float) <B>return</B> Float;<BR>
<B>function</B> Exp (X : Float) <B>return</B> Float;<BR>
<B>private</B><BR>
<B>pragma</B> Import(Fortran, Sqrt);<BR>
<B>pragma</B> Import(Fortran, Exp);<BR>
<B>end</B> Fortran_Library;</TT></DIV>
<HR>
<P><A HREF="RM-TOC.html">Contents</A> <A HREF="RM-0-29.html">Index</A> <A HREF="RM-B.html">Previous</A> <A HREF="RM-B-2.html">Next</A> <A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>
|