File: AA-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 (498 lines) | stat: -rw-r--r-- 44,343 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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - 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="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-B-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-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;{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
<A NAME="I6348"></A><A NAME="I6349"></A>The facilities relevant to interfacing
with the C language are the package Interfaces.C and its children; <S>and
</S>support for the Import, Export, and Convention pragmas with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C<U>; and support for the Convention pragma with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C_Pass_By_Copy</U>.</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="I6350"></A><A NAME="I6351"></A><A NAME="I6352"></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="I6353"></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="I6354"></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="I6355"></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="I6356"></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="I6357"></A><A NAME="I6358"></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="I6359"></A><A NAME="I6360"></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="I6361"></A><A NAME="I6362"></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="I6363"></A><A NAME="I6364"></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="I6365"></A><A NAME="I6366"></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="I6367"></A><A NAME="I6368"></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="I6369"></A><A NAME="I6370"></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="I6371"></A><A NAME="I6372"></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="I6373"></A><A NAME="I6374"></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="I6375"></A><A NAME="I6376"></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="I6377"></A><A NAME="I6378"></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="I6379"></A><A NAME="I6380"></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="I6381"></A><A NAME="I6382"></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="I6383"></A><A NAME="I6384"></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="I6385"></A><A NAME="I6386"></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>{<I><A HREF="defect1.html#8652/0060">8652/0060</A></I>}
<BR>
&nbsp;&nbsp;&nbsp;<A NAME="I6387"></A>nul&nbsp;:&nbsp;<B>constant</B>&nbsp;char&nbsp;:=&nbsp;<U><I>implementation-defined</I></U><S>char'First</S>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6388"></A><A NAME="I6389"></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="I6390"></A><A NAME="I6391"></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="I6392"></A><A NAME="I6393"></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="I6394"></A><A NAME="I6395"></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="I6396"></A><A NAME="I6397"></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="I6398"></A><A NAME="I6399"></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="I6400"></A><A NAME="I6401"></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="I6402"></A><A NAME="I6403"></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>{<I><A HREF="defect1.html#8652/0060">8652/0060</A></I>}
<BR>
&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;<A NAME="I6404"></A><A NAME="I6405"></A>wchar_t&nbsp;<B>is</B>&nbsp;<U><I>&lt;implementation-defined&nbsp;character&nbsp;type&gt;</I></U><S><I>implementation-defined</I></S>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31/1</FONT></DIV>
<DIV Class="Examples"><TT>{<I><A HREF="defect1.html#8652/0060">8652/0060</A></I>}
<BR>
&nbsp;&nbsp;&nbsp;<A NAME="I6406"></A>wide_nul&nbsp;:&nbsp;<B>constant</B>&nbsp;wchar_t&nbsp;:=&nbsp;<U><I>implementation-defined</I></U><S>wchar_t'First</S>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DIV Class="Examples"><TT>&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;<A NAME="I6407"></A><A NAME="I6408"></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="I6409"></A><A NAME="I6410"></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="I6411"></A><A NAME="I6412"></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="I6413"></A><A NAME="I6414"></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="I6415"></A><A NAME="I6416"></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="I6417"></A><A NAME="I6418"></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="I6419"></A><A NAME="I6420"></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="I6421"></A><A NAME="I6422"></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="I6423"></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>41.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B><U>The
definitions of types and constants in Interfaces.C.</U></FONT></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>46.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation Note: </B>{<I><A HREF="defect2.html#8652/0114">8652/0114</A></I>}
<U>The To_C and To_Ada functions map between corresponding characters,
not necessarily between characters with the same internal representation.
Corresponding characters are characters defined by the same enumeration
literal, if such exist; otherwise, the correspondence is unspecified.<A NAME="I6424"></A></U></FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46.a.2/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><U>The following definition is
equivalent to the above summary:</U></FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46.a.3/1</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><U><TT>To_C
(Latin_1_Char) = char'Value(Character'Image(Latin_1_Char))</TT><BR>
provided that char'Value does not raise an exception; otherwise the result
is unspecified.</U></FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>46.a.4/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><U><TT>To_Ada (Native_C_Char)
= Character'Value(char'Image(Native_C_Char))</TT><BR>
provided that Character'Value does not raise an exception; otherwise
the result is unspecified.</U> </FONT></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="I6425"></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="I6426"></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.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The Interfaces.C
package provides an implementation-defined character type, char, designed
to model the C run-time character set, and mappings between the types
char and Character.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.b</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1>One
application of the C interface package is to compose a C string and pass
it to a C function. One way to do this is for the programmer to declare
an object that will hold the C array, and then pass this array to the
C function. This is realized via the type char_array: </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.c</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>type</B>&nbsp;char_array&nbsp;<B>is</B>&nbsp;<B>array</B>&nbsp;(size_t&nbsp;<B>range</B>&nbsp;&lt;&gt;)&nbsp;of&nbsp;Char;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.d</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>The programmer can declare an
Ada String, convert it to a char_array, and pass the char_array as actual
parameter to the C function that is expecting a char *.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.e</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>An alternative approach is for
the programmer to obtain a C char pointer from an Ada String (or from
a char_array) by invoking an allocation function. The package Interfaces.C.Strings
(see below) supplies the needed facilities, including a private type
chars_ptr that corresponds to C's char *, and two allocation functions.
To avoid storage leakage, a Free procedure releases the storage that
was allocated by one of these allocate functions.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.f</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>It is typical for a C function
that deals with strings to adopt the convention that the string is delimited
by a nul char. The C interface packages support this convention. A constant
nul of type Char is declared, and the function Value(Chars_Ptr) in Interfaces.C.Strings
returns a char_array up to and including the first nul in the array that
the chars_ptr points to. The Allocate_Chars function allocates an array
that is nul terminated.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.g</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>Some C functions that deal with
strings take an explicit length as a parameter, thus allowing strings
to be passed that contain nul as a data element. Other C functions take
an explicit length that is an upper bound: the prefix of the string up
to the char before nul, or the prefix of the given length, is used by
the function, whichever is shorter. The C Interface packages support
calling such functions. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
<U>A Convention pragma with <I>convention</I>_<FONT FACE="Arial, Helvetica">identifier</FONT>
C_Pass_By_Copy shall only be applied to a type.</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.2/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
<U>The eligibility rules in <A HREF="AA-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.</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>60.3/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
<U>If a type is C_Pass_By_Copy-compatible then it is also C-compatible.</U></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;{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
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="AA-B-1.html">B.1</A>)<U>. 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.</U> </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;{<I><A HREF="defect1.html#8652/0060">8652/0060</A></I>}
<U>The constants nul and wide_nul should have a representation of zero.</U></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>64.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>The programmer
can also choose an Ada procedure when the C function returns an int that
is to be discarded.</FONT></DIV>
<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>{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
<U>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.</U></LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>69/1</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>{<I><A HREF="defect1.html#8652/0059">8652/0059</A></I>}
An Ada parameter of a record type T, of any mode, <U>other than an <B>in</B>
parameter of a C_Pass_By_Copy-compatible type,</U> 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="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-B-2.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-B-3-1.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>