File: RM-B-3.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (421 lines) | stat: -rw-r--r-- 39,019 bytes parent folder | download
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>Ada95 - Interfacing with C</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>&nbsp;&nbsp;&nbsp;<A HREF="RM-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-B-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-B-3-1.html">Next</A></P>
<HR>
<H1> B.3 Interfacing with C</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I6074"></A><A NAME="I6075"></A>The
facilities relevant to interfacing with the C language are the package
Interfaces.C and its children; support for the Import, Export, and Convention
pragmas with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C; and support for the Convention pragma with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C_Pass_By_Copy.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;The package Interfaces.C contains the basic types,
constants and subprograms that allow an Ada program to pass scalars and
strings to C functions. </DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;The library package
Interfaces.C has the following declaration: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B>&nbsp;Interfaces.C&nbsp;<B>is</B><A NAME="I6076"></A><A NAME="I6077"></A><A NAME="I6078"></A><BR>
&nbsp;&nbsp;&nbsp;<B>pragma</B>&nbsp;Pure(C);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Declarations&nbsp;based&nbsp;on&nbsp;C's&nbsp;&lt;limits.h&gt;</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<A NAME="I6079"></A>CHAR_BIT&nbsp;&nbsp;:&nbsp;<B>constant</B>&nbsp;:=&nbsp;<I>implementation-defined</I>;&nbsp;&nbsp;<I>--&nbsp;typically&nbsp;8</I><BR>
&nbsp;&nbsp;&nbsp;<A NAME="I6080"></A>SCHAR_MIN&nbsp;:&nbsp;<B>constant</B>&nbsp;:=&nbsp;<I>implementation-defined</I>;&nbsp;&nbsp;<I>--&nbsp;typically&nbsp;-128</I><BR>
&nbsp;&nbsp;&nbsp;<A NAME="I6081"></A>SCHAR_MAX&nbsp;:&nbsp;<B>constant</B>&nbsp;:=&nbsp;<I>implementation-defined</I>;&nbsp;&nbsp;<I>--&nbsp;typically&nbsp;127</I><BR>
&nbsp;&nbsp;&nbsp;<A NAME="I6082"></A>UCHAR_MAX&nbsp;:&nbsp;<B>constant</B>&nbsp;:=&nbsp;<I>implementation-defined</I>;&nbsp;&nbsp;<I>--&nbsp;typically&nbsp;255</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Signed&nbsp;and&nbsp;Unsigned&nbsp;Integers</I><BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6083"></A><A NAME="I6084"></A>int&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;<I>implementation-defined</I>;<BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6085"></A><A NAME="I6086"></A>short&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;<I>implementation-defined</I>;<BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6087"></A><A NAME="I6088"></A>long&nbsp;&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6089"></A><A NAME="I6090"></A>signed_char&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;SCHAR_MIN&nbsp;..&nbsp;SCHAR_MAX;<BR>
&nbsp;&nbsp;&nbsp;<B>for</B>&nbsp;signed_char'Size&nbsp;<B>use</B>&nbsp;CHAR_BIT;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6091"></A><A NAME="I6092"></A>unsigned&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>mod</B>&nbsp;<I>implementation-defined</I>;<BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6093"></A><A NAME="I6094"></A>unsigned_short&nbsp;<B>is</B>&nbsp;<B>mod</B>&nbsp;<I>implementation-defined</I>;<BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6095"></A><A NAME="I6096"></A>unsigned_long&nbsp;&nbsp;<B>is</B>&nbsp;<B>mod</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6097"></A><A NAME="I6098"></A>unsigned_char&nbsp;<B>is</B>&nbsp;<B>mod</B>&nbsp;(UCHAR_MAX+1);<BR>
&nbsp;&nbsp;&nbsp;<B>for</B>&nbsp;unsigned_char'Size&nbsp;<B>use</B>&nbsp;CHAR_BIT;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>subtype</B>&nbsp;<A NAME="I6099"></A><A NAME="I6100"></A>plain_char&nbsp;<B>is</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6101"></A><A NAME="I6102"></A>ptrdiff_t&nbsp;<B>is</B>&nbsp;<B>range</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6103"></A><A NAME="I6104"></A>size_t&nbsp;<B>is</B>&nbsp;<B>mod</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Floating&nbsp;Point</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6105"></A><A NAME="I6106"></A>C_float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>digits</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6107"></A><A NAME="I6108"></A>double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>is</B>&nbsp;<B>digits</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6109"></A><A NAME="I6110"></A>long_double&nbsp;<B>is</B>&nbsp;<B>digits</B>&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Characters&nbsp;and&nbsp;Strings&nbsp;</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6111"></A><A NAME="I6112"></A>char&nbsp;<B>is</B>&nbsp;<I>&lt;implementation-defined&nbsp;character&nbsp;type&gt;</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20/1</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<A NAME="I6113"></A>nul&nbsp;:&nbsp;<B>constant</B>&nbsp;char&nbsp;:=&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6114"></A><A NAME="I6115"></A>To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;Character)&nbsp;<B>return</B>&nbsp;char;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6116"></A><A NAME="I6117"></A>To_Ada&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;char)&nbsp;<B>return</B>&nbsp;Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6118"></A><A NAME="I6119"></A>char_array&nbsp;<B>is</B>&nbsp;<B>array</B>&nbsp;(size_t&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;<B>aliased</B>&nbsp;char;<BR>
&nbsp;&nbsp;&nbsp;<B>pragma</B>&nbsp;Pack(char_array);<BR>
&nbsp;&nbsp;&nbsp;<B>for</B>&nbsp;char_array'Component_Size&nbsp;<B>use</B>&nbsp;CHAR_BIT;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6120"></A><A NAME="I6121"></A>Is_Nul_Terminated&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;char_array)&nbsp;<B>return</B>&nbsp;Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6122"></A><A NAME="I6123"></A>To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;char_array;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6124"></A><A NAME="I6125"></A>To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;<A NAME="I6126"></A><A NAME="I6127"></A>To_C&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;size_t;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;<A NAME="I6128"></A><A NAME="I6129"></A>To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Natural;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Wide&nbsp;Character&nbsp;and&nbsp;Wide&nbsp;String</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>30/1</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6130"></A><A NAME="I6131"></A>wchar_t&nbsp;<B>is</B>&nbsp;<I>&lt;implementation-defined&nbsp;character&nbsp;type&gt;</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31/1</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<A NAME="I6132"></A>wide_nul&nbsp;:&nbsp;<B>constant</B>&nbsp;wchar_t&nbsp;:=&nbsp;<I>implementation-defined</I>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6133"></A><A NAME="I6134"></A>To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;Wide_Character)&nbsp;<B>return</B>&nbsp;wchar_t;<BR>
&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6135"></A><A NAME="I6136"></A>To_Ada&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;<B>return</B>&nbsp;Wide_Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6137"></A><A NAME="I6138"></A>wchar_array&nbsp;<B>is</B>&nbsp;<B>array</B>&nbsp;(size_t&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;<B>of</B>&nbsp;<B>aliased</B>&nbsp;wchar_t;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>pragma</B>&nbsp;Pack(wchar_array);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6139"></A><A NAME="I6140"></A>Is_Nul_Terminated&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_array)&nbsp;<B>return</B>&nbsp;Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6141"></A><A NAME="I6142"></A>To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;wchar_array;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6143"></A><A NAME="I6144"></A>To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;Wide_String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;<A NAME="I6145"></A><A NAME="I6146"></A>To_C&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;size_t;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;<A NAME="I6147"></A><A NAME="I6148"></A>To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Natural;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<A NAME="I6149"></A>Terminator_Error&nbsp;:&nbsp;<B>exception</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>41</FONT></DIV>
<DIV Class="Examples"><TT><B>end</B>&nbsp;Interfaces.C;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>42</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;Each of the types declared in Interfaces.C is
C-compatible.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>43</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;The types int, short, long, unsigned, ptrdiff_t,
size_t, double, char, and wchar_t correspond respectively to the C types
having the same names. The types signed_char, unsigned_short, unsigned_long,
unsigned_char, C_float, and long_double correspond respectively to the
C types signed char, unsigned short, unsigned long, unsigned char, float,
and long double.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>44</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.9em">&nbsp;&nbsp;&nbsp;&nbsp;The type of the
subtype plain_char is either signed_char or unsigned_char, depending
on the C implementation. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>45</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;Character)&nbsp;<B>return</B>&nbsp;char;<BR>
<B>function</B>&nbsp;To_Ada&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;<B>return</B>&nbsp;Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The functions
To_C and To_Ada map between the Ada type Character and the C type char.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>47</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;Is_Nul_Terminated&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;char_array)&nbsp;<B>return</B>&nbsp;Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>48</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The result of
Is_Nul_Terminated is True if Item contains nul, and is False otherwise.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>49</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;String;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;char_array;<BR>
<BR>
<B>function</B>&nbsp;To_Ada&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;char_array;&nbsp;Trim_Nul&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;String;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>50</FONT></DIV>
<DIV Class="CodeIndented">The result of To_C is a char_array value of
length Item'Length (if Append_Nul is False) or Item'Length+1 (if Append_Nul
is True). The lower bound is 0. For each component Item(I), the corresponding
component in the result is To_C applied to Item(I). The value nul is
appended if Append_Nul is True.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>51</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The result of
To_Ada is a String whose length is Item'Length (if Trim_Nul is False)
or the length of the slice of Item preceding the first nul (if Trim_Nul
is True). The lower bound of the result is 1. If Trim_Nul is False, then
for each component Item(I) the corresponding component in the result
is To_Ada applied to Item(I). If Trim_Nul is True, then for each component
Item(I) before the first nul the corresponding component in the result
is To_Ada applied to Item(I). The function propagates Terminator_Error
if Trim_Nul is True and Item does not contain nul.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>52</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B>&nbsp;To_C&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;size_t;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);<BR>
<BR>
<B>procedure</B>&nbsp;To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Natural;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>53</FONT></DIV>
<DIV Class="CodeIndented">For procedure To_C, each element of Item is
converted (via the To_C function) to a char, which is assigned to the
corresponding element of Target. If Append_Nul is True, nul is then assigned
to the next element of Target. In either case, Count is set to the number
of Target elements assigned. <A NAME="I6150"></A>If Target is not long
enough, Constraint_Error is propagated.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>54</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">For procedure
To_Ada, each element of Item (if Trim_Nul is False) or each element of
Item preceding the first nul (if Trim_Nul is True) is converted (via
the To_Ada function) to a Character, which is assigned to the corresponding
element of Target. Count is set to the number of Target elements assigned.
<A NAME="I6151"></A>If Target is not long enough, Constraint_Error is
propagated. If Trim_Nul is True and Item does not contain nul, then Terminator_Error
is propagated.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>55</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;Is_Nul_Terminated&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_array)&nbsp;<B>return</B>&nbsp;Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>56</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">The result of
Is_Nul_Terminated is True if Item contains wide_nul, and is False otherwise.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>57</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;Wide_Character)&nbsp;<B>return</B>&nbsp;wchar_t;<BR>
<B>function</B>&nbsp;To_Ada&nbsp;(Item&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)&nbsp;<B>return</B>&nbsp;Wide_Character;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>58</FONT></DIV>
<DIV Class="CodeIndented" Style="margin-bottom: 0.9em">To_C and To_Ada
provide the mappings between the Ada and C wide character types.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>59</FONT></DIV>
<DIV Class="Examples"><TT><B>function</B>&nbsp;To_C&nbsp;&nbsp;&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;wchar_array;<BR>
<BR>
<B>function</B>&nbsp;To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;Wide_String;<BR>
<BR>
<B>procedure</B>&nbsp;To_C&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;size_t;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Append_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);<BR>
<BR>
<B>procedure</B>&nbsp;To_Ada&nbsp;(Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;wchar_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Wide_String;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<B>out</B>&nbsp;Natural;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trim_Nul&nbsp;:&nbsp;<B>in</B>&nbsp;Boolean&nbsp;:=&nbsp;True);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60</FONT></DIV>
<DIV Class="CodeIndented">The To_C and To_Ada subprograms that convert
between Wide_String and wchar_array have analogous effects to the To_C
and To_Ada subprograms that convert between String and char_array, except
that wide_nul is used instead of nul. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A Convention pragma with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C_Pass_By_Copy shall only be applied to a type.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.2/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The eligibility rules in <A HREF="RM-B-1.html">B.1</A>
do not apply to convention C_Pass_By_Copy. Instead, a type T is eligible
for convention C_Pass_By_Copy if T is a record type that has no discriminants
and that only has components with statically constrained subtypes, and
each component is C-compatible.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.3/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If a type is C_Pass_By_Copy-compatible then
it is also C-compatible.</DIV>

<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>61/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;An implementation shall support pragma Convention
with a C <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
for a C-eligible type (see <A HREF="RM-B-1.html">B.1</A>). An implementation
shall support pragma Convention with a C_Pass_By_Copy <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
for a C_Pass_By_Copy-eligible type. </DIV>

<H4 ALIGN=CENTER>Implementation Permissions</H4>
<DIV Class="Paranum"><FONT SIZE=-2>62</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;An implementation may provide additional declarations
in the C interface packages. </DIV>

<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>62.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The constants nul and wide_nul should have
a representation of zero.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>63</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;An implementation should support the following
interface correspondences between Ada and C. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>64</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada procedure corresponds to a void-returning C function.
</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>65</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada function corresponds to a non-void C function.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>66</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada <B>in</B> scalar parameter is passed as a scalar
argument to a C function.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>67</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada <B>in</B> parameter of an access-to-object type
with designated type T is passed as a t* argument to a C function, where
t is the C type corresponding to the Ada type T.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>68</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada <B>access</B> T parameter, or an Ada <B>out</B>
or <B>in out</B> parameter of an elementary type T, is passed as a t*
argument to a C function, where t is the C type corresponding to the
Ada type T. In the case of an elementary <B>out</B> or <B>in out</B>
parameter, a pointer to a temporary copy is used to preserve by-copy
semantics.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>68.1/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada parameter of a C_Pass_By_Copy-compatible (record)
type T, of mode <B>in</B>, is passed as a t argument to a C function,
where t is the C struct corresponding to the Ada type T.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>69/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada parameter of a record type T, of any mode, other
than an <B>in</B> parameter of a C_Pass_By_Copy-compatible type, is passed
as a t* argument to a C function, where t is the C struct corresponding
to the Ada type T.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>70</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada parameter of an array type with component type T,
of any mode, is passed as a t* argument to a C function, where t is the
C type corresponding to the Ada type T.</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>71</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>An Ada parameter of an access-to-subprogram type is passed
as a pointer to a C function whose prototype corresponds to the designated
subprogram's specification. </LI></UL>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>72</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>9&nbsp;&nbsp;Values of type char_array
are not implicitly terminated with nul. If a char_array is to be passed
as a parameter to an imported C function requiring nul termination, it
is the programmer's responsibility to obtain this effect.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>73</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>10&nbsp;&nbsp;To obtain the effect of
C's sizeof(item_type), where Item_Type is the corresponding Ada type,
evaluate the expression: size_t(Item_Type'Size/CHAR_BIT).</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>74</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>11&nbsp;&nbsp;There is no explicit support
for C's union types. Unchecked conversions can be used to obtain the
effect of C unions.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>75</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>12&nbsp;&nbsp;A C function that takes
a variable number of arguments can correspond to several Ada subprograms,
taking various specific numbers and types of parameters. </FONT></DIV>

<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>76</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Example of using
the Interfaces.C package:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>77</FONT></DIV>
<DIV Class="Examples"><TT><I>--Calling&nbsp;the&nbsp;C&nbsp;Library&nbsp;Function&nbsp;strcpy</I><BR>
<B>with</B>&nbsp;Interfaces.C;<BR>
<B>procedure</B>&nbsp;Test&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;<B>package</B>&nbsp;C&nbsp;<B>renames</B>&nbsp;Interfaces.C;<BR>
&nbsp;&nbsp;&nbsp;<B>use</B>&nbsp;<B>type</B>&nbsp;C.char_array;<BR>
&nbsp;&nbsp;&nbsp;<I>--&nbsp;Call&nbsp;&lt;string.h&gt;strcpy:</I><BR>
&nbsp;&nbsp;&nbsp;<I>--&nbsp;C&nbsp;definition&nbsp;of&nbsp;strcpy:&nbsp;&nbsp;char&nbsp;*strcpy(char&nbsp;*s1,&nbsp;const&nbsp;char&nbsp;*s2);</I><BR>
&nbsp;&nbsp;&nbsp;<I>--&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;function&nbsp;copies&nbsp;the&nbsp;string&nbsp;pointed&nbsp;to&nbsp;by&nbsp;s2&nbsp;(including&nbsp;the&nbsp;terminating&nbsp;null&nbsp;character)</I><BR>
&nbsp;&nbsp;&nbsp;<I>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;into&nbsp;the&nbsp;array&nbsp;pointed&nbsp;to&nbsp;by&nbsp;s1.&nbsp;If&nbsp;copying&nbsp;takes&nbsp;place&nbsp;between&nbsp;objects&nbsp;that&nbsp;overlap,&nbsp;</I><BR>
&nbsp;&nbsp;&nbsp;<I>--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;behavior&nbsp;is&nbsp;undefined.&nbsp;The&nbsp;strcpy&nbsp;function&nbsp;returns&nbsp;the&nbsp;value&nbsp;of&nbsp;s1.</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>78</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<I>--&nbsp;Note:&nbsp;since&nbsp;the&nbsp;C&nbsp;function's&nbsp;return&nbsp;value&nbsp;is&nbsp;of&nbsp;no&nbsp;interest,&nbsp;the&nbsp;Ada&nbsp;interface&nbsp;is&nbsp;a&nbsp;procedure</I><BR>
&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Strcpy&nbsp;(Target&nbsp;:&nbsp;<B>out</B>&nbsp;C.char_array;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Source&nbsp;:&nbsp;<B>in</B>&nbsp;&nbsp;C.char_array);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>79</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>pragma</B>&nbsp;Import(C,&nbsp;Strcpy,&nbsp;&quot;strcpy&quot;);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>80</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;Chars1&nbsp;:&nbsp;&nbsp;C.char_array(1..20);<BR>
&nbsp;&nbsp;&nbsp;Chars2&nbsp;:&nbsp;&nbsp;C.char_array(1..20);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>81</FONT></DIV>
<DIV Class="Examples"><TT><B>begin</B><BR>
&nbsp;&nbsp;&nbsp;Chars2(1..6)&nbsp;:=&nbsp;&quot;qwert&quot;&nbsp;&amp;&nbsp;C.nul;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>82</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;Strcpy(Chars1,&nbsp;Chars2);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>83</FONT></DIV>
<DIV Class="Examples"><TT><I>--&nbsp;Now&nbsp;Chars1(1..6)&nbsp;=&nbsp;&quot;qwert&quot;&nbsp;&amp;&nbsp;C.Nul</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>84</FONT></DIV>
<DIV Class="Examples"><TT><B>end</B>&nbsp;Test;</TT></DIV>

<HR>
<P><A HREF="RM-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-B-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-B-3-1.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="RM-TTL.html">Legal</A></P>
</BODY>
</HTML>