File: h2xs.html

package info (click to toggle)
perl-doc-html 5.26.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 39,400 kB
  • sloc: xml: 36; makefile: 7
file content (762 lines) | stat: -rw-r--r-- 36,179 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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>h2xs - perldoc.perl.org</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta http-equiv="Content-Language" content="en-gb">
  <link rel="search" type="application/opensearchdescription+xml" title="Search perldoc.perl.org" href="/static/search.xml"/>
  <link href="static/css-20100830.css" rel="stylesheet" rev="stylesheet" type="text/css" media="screen">
  <link href="static/exploreperl.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>

<body onLoad="perldoc.startup();" onPageShow="if (event.persisted) perldoc.startup();">
    <div id="page">
      
      <div id="header">
	<div id="homepage_link">
	  <a href="index.html"></a>
	</div>
	<div id="strapline">
	  Perl Programming Documentation
	</div>
	<div id="download_link" class="download">
	  <a href="http://www.perl.org/get.html">Download Perl</a>
	</div>
	<div id="explore_link" class="download">
	  <a id="explore_anchor" href="#">Explore</a>
	</div>
      </div>
      
      <div id="body">
        <div id="left_column">
          <div class="side_group">
            
	    <div class="side_panel doc_panel">
              <p>Manual</p>
              <ul>
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">History / Changes</a>
                <li><a href="index-licence.html">License</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Reference</p>
              <ul>
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Special Variables</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platform Specific</a>
              </ul>
            </div>
            <div class="side_panel doc_panel">
              <p>Modules</p>
              <ul>
		<li>
		
                
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		    
		  
		
                  
		
                  
		
                  
		    
		  
		
                  
		
                  
		
		
                    <a href="index-modules-A.html">A</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-B.html">B</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-C.html">C</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-D.html">D</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-E.html">E</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-F.html">F</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-G.html">G</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-H.html">H</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-I.html">I</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-L.html">L</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-M.html">M</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-N.html">N</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-O.html">O</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-P.html">P</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-S.html">S</a>
                    
                      
                        <li>
                      
                    
                
                    <a href="index-modules-T.html">T</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-U.html">U</a>
                    
                      
                        &bull;
                      
                    
                
                    <a href="index-modules-X.html">X</a>
                    
                
              </ul>
            </div>
            
	      <div class="side_panel doc_panel">
		<p>Tools</p>
		<ul>
		  <li><a href="preferences.html">Preferences</a>
		</ul>
	      </div>
            
          </div>
        </div>
        <div id="centre_column">
          <div id="content_header">
            <div id="title_bar">
              <div id="page_name">
                <h1>h2xs</h1>
              </div>
              <div id="perl_version">
                Perl 5 version 26.0 documentation
              </div>
              <div class="page_links" id="page_links_top">
                <a href="#" onClick="toolbar.goToTop();return false;">Go to top</a>
		
              </div>
	      <div class="page_links" id="page_links_bottom">
		
                  <a href="#" id="page_index_toggle">Show page index</a> &bull;
		
                <a href="#" id="recent_pages_toggle">Show recent pages</a>		
	      </div>
	      <div id="search_form">
		<form action="search.html" method="GET" id="search">
		  <input type="text" name="q" id="search_box" alt="Search">
		</form>
	      </div>
            </div>
            <div id="breadcrumbs">
                
    <a href="index.html">Home</a> &gt;
    
      
        <a href="index-utilities.html">Utilities</a> &gt;
      
    
    h2xs
  

            </div>
          </div>
          <div id="content_body">
	    <!--[if lt IE 7]>
 <div class="noscript">
   <p>
     <strong>It looks like you're using Internet Explorer 6. This is a very old
     browser which does not offer full support for modern websites.</strong>
   </p>
   <p>
     Unfortunately this means that this website will not work on
     your computer.
   </p>
   <p>
     Don't miss out though! To view the site (and get a better experience from
     many other websites), simply upgrade to
     <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet
Explorer 8</a>
     or download an alternative browser such as
     <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>,
     <a href="http://www.apple.com/safari/download/">Safari</a>, or
     <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
   </p>
   <p>
     All of these browsers are free. If you're using a PC at work, you may
     need to contact your IT administrator.
   </p>
 </div>
<![endif]-->
	    <noscript>
	      <div class="noscript">
	      <p>
                <strong>Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled,
	        or are running a non-JavaScript capable web browser.</strong>
	      </p>
	      <p>
		To get the best experience, please enable JavaScript or download a modern web browser such as <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8</a>, <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a>, <a href="http://www.apple.com/safari/download/">Safari</a>, or <a href="http://www.google.co.uk/chrome">Google Chrome</a>.
              </p>
	      </div>
	    </noscript>

	    <div id="recent_pages" class="hud_container">
	      <div id="recent_pages_header" class="hud_header">
		<div id="recent_pages_close" class="hud_close"><a href="#" onClick="recentPages.hide();return false;"></a></div>
		<div id="recent_pages_title" class="hud_title"><span class="hud_span_top">Recently read</span></div>
		<div id="recent_pages_topright" class="hud_topright"></div>
	      </div>
	      <div id="recent_pages_content" class="hud_content">
	      </div>
	      <div id="recent_pages_footer" class="hud_footer">
		<div id="recent_pages_bottomleft" class="hud_bottomleft"></div>
		<div id="recent_pages_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
		<div id="recent_pages_resize" class="hud_resize"></div>
	      </div>
	    </div>
  
	    <div id="from_search"></div>
            <h1>h2xs</h1>


  <!--    -->
<ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#OPTIONS">OPTIONS</a><li><a href="#EXAMPLES">EXAMPLES</a><ul><li><a href="#Extension-based-on-_.h_-and-_.c_-files">Extension based on _.h_ and _.c_ files</a></ul><li><a href="#ENVIRONMENT">ENVIRONMENT</a><li><a href="#AUTHOR">AUTHOR</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#DIAGNOSTICS">DIAGNOSTICS</a><li><a href="#LIMITATIONS-of-*-x*">LIMITATIONS of *-x*</a></ul><a name="NAME"></a><h1>NAME</h1>
<p>h2xs - convert .h C header files to Perl extensions</p>
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
<p><b>h2xs</b> [<b>OPTIONS</b> ...] [headerfile ... [extra_libraries]]</p>
<p><b>h2xs</b> <b>-h</b>|<b>-?</b>|<b>--help</b></p>
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
<p><i>h2xs</i> builds a Perl extension from C header files.  The extension
will include functions which can be used to retrieve the value of any
#define statement which was in the C header files.</p>
<p>The <i>module_name</i> will be used for the name of the extension.  If
module_name is not supplied then the name of the first header file
will be used, with the first character capitalized.</p>
<p>If the extension might need extra libraries, they should be included
here.  The extension Makefile.PL will take care of checking whether
the libraries actually exist and how they should be loaded.  The extra
libraries should be specified in the form -lm -lposix, etc, just as on
the cc command line.  By default, the Makefile.PL will search through
the library path determined by Configure.  That path can be augmented
by including arguments of the form <b>-L/another/library/path</b> in the
extra-libraries argument.</p>
<p>In spite of its name, <i>h2xs</i> may also be used to create a skeleton pure
Perl module. See the <b>-X</b> option.</p>
<a name="OPTIONS"></a><h1>OPTIONS</h1>
<ul>
<li><a name="*-A*%2c-*--omit-autoload*"></a><b><b>-A</b>, <b>--omit-autoload</b></b>
<p>Omit all autoload facilities.  This is the same as <b>-c</b> but also
removes the <code class="inline"><a class="l_k" href="functions/use.html">use</a> <span class="w">AutoLoader</span></code>
 statement from the .pm file.</p>
</li>
<li><a name="*-B*%2c-*--beta-version*"></a><b><b>-B</b>, <b>--beta-version</b></b>
<p>Use an alpha/beta style version number.  Causes version number to
be "0.00_01" unless <b>-v</b> is specified.</p>
</li>
<li><a name="*-C*%2c-*--omit-changes*"></a><b><b>-C</b>, <b>--omit-changes</b></b>
<p>Omits creation of the <i>Changes</i> file, and adds a HISTORY section to
the POD template.</p>
</li>
<li><a name="*-F*%2c-*--cpp-flags*%3d_addflags_"></a><b><b>-F</b>, <b>--cpp-flags</b>=<i>addflags</i></b>
<p>Additional flags to specify to C preprocessor when scanning header for
function declarations.  Writes these options in the generated <i>Makefile.PL</i>
too.</p>
</li>
<li><a name="*-M*%2c-*--func-mask*%3d_regular-expression_"></a><b><b>-M</b>, <b>--func-mask</b>=<i>regular expression</i></b>
<p>selects functions/macros to process.</p>
</li>
<li><a name="*-O*%2c-*--overwrite-ok*"></a><b><b>-O</b>, <b>--overwrite-ok</b></b>
<p>Allows a pre-existing extension directory to be overwritten.</p>
</li>
<li><a name="*-P*%2c-*--omit-pod*"></a><b><b>-P</b>, <b>--omit-pod</b></b>
<p>Omit the autogenerated stub POD section.</p>
</li>
<li><a name="*-X*%2c-*--omit-XS*"></a><b><b>-X</b>, <b>--omit-XS</b></b>
<p>Omit the XS portion. Used to generate a skeleton pure Perl module.
<code class="inline">-c</code>
 and <code class="inline">-f</code>
 are implicitly enabled.</p>
</li>
<li><a name="*-a*%2c-*--gen-accessors*"></a><b><b>-a</b>, <b>--gen-accessors</b></b>
<p>Generate an accessor method for each element of structs and unions. The
generated methods are named after the element name; will return the current
value of the element if called without additional arguments; and will set
the element to the supplied value (and return the new value) if called with
an additional argument. Embedded structures and unions are returned as a
pointer rather than the complete structure, to facilitate chained calls.</p>
<p>These methods all apply to the Ptr type for the structure; additionally
two methods are constructed for the structure type itself, <code class="inline"><span class="w">_to_ptr</span></code>

which returns a Ptr type pointing to the same structure, and a <code class="inline"><span class="w">new</span></code>

method to construct and return a new structure, initialised to zeroes.</p>
</li>
<li><a name="*-b*%2c-*--compat-version*%3d_version_"></a><b><b>-b</b>, <b>--compat-version</b>=<i>version</i></b>
<p>Generates a .pm file which is backwards compatible with the specified
perl version.</p>
<p>For versions &lt; 5.6.0, the changes are.
    - no use of 'our' (uses 'use vars' instead)
    - no 'use warnings'</p>
<p>Specifying a compatibility version higher than the version of perl you
are using to run h2xs will have no effect.  If unspecified h2xs will default
to compatibility with the version of perl you are using to run h2xs.</p>
</li>
<li><a name="*-c*%2c-*--omit-constant*"></a><b><b>-c</b>, <b>--omit-constant</b></b>
<p>Omit <code class="inline"><span class="i">constant</span><span class="s">(</span><span class="s">)</span></code>
 from the .xs file and corresponding specialised
<code class="inline">AUTOLOAD</code>
 from the .pm file.</p>
</li>
<li><a name="*-d*%2c-*--debugging*"></a><b><b>-d</b>, <b>--debugging</b></b>
<p>Turn on debugging messages.</p>
</li>
<li><a name="*-e*%2c-*--omit-enums*%3d%5b_regular-expression_%5d"></a><b><b>-e</b>, <b>--omit-enums</b>=[<i>regular expression</i>]</b>
<p>If <i>regular expression</i> is not given, skip all constants that are defined in
a C enumeration. Otherwise skip only those constants that are defined in an
enum whose name matches <i>regular expression</i>.</p>
<p>Since <i>regular expression</i> is optional, make sure that this switch is followed
by at least one other switch if you omit <i>regular expression</i> and have some
pending arguments such as header-file names. This is ok:</p>
<pre class="verbatim"><ol><li>    <span class="w">h2xs</span> -e -<span class="w">n</span> <span class="w">Module::Foo</span> <span class="w">foo</span>.<span class="w">h</span></li></ol></pre><p>This is not ok:</p>
<pre class="verbatim"><ol><li>    <span class="w">h2xs</span> -<span class="w">n</span> <span class="w">Module::Foo</span> -e <span class="w">foo</span>.<span class="w">h</span></li></ol></pre><p>In the latter, foo.h is taken as <i>regular expression</i>.</p>
</li>
<li><a name="*-f*%2c-*--force*"></a><b><b>-f</b>, <b>--force</b></b>
<p>Allows an extension to be created for a header even if that header is
not found in standard include directories.</p>
</li>
<li><a name="*-g*%2c-*--global*"></a><b><b>-g</b>, <b>--global</b></b>
<p>Include code for safely storing static data in the .xs file.
Extensions that do no make use of static data can ignore this option.</p>
</li>
<li><a name="*-h*%2c-*-%3f*%2c-*--help*"></a><b><b>-h</b>, <b>-?</b>, <b>--help</b></b>
<p>Print the usage, help and version for this h2xs and exit.</p>
</li>
<li><a name="*-k*%2c-*--omit-const-func*"></a><b><b>-k</b>, <b>--omit-const-func</b></b>
<p>For function arguments declared as <code class="inline"><span class="w">const</span></code>
, omit the const attribute in the
generated XS code.</p>
</li>
<li><a name="*-m*%2c-*--gen-tied-var*"></a><b><b>-m</b>, <b>--gen-tied-var</b></b>
<p><b>Experimental</b>: for each variable declared in the header file(s), declare
a perl variable of the same name magically tied to the C variable.</p>
</li>
<li><a name="*-n*%2c-*--name*%3d_module_name_"></a><b><b>-n</b>, <b>--name</b>=<i>module_name</i></b>
<p>Specifies a name to be used for the extension, e.g., -n RPC::DCE</p>
</li>
<li><a name="*-o*%2c-*--opaque-re*%3d_regular-expression_"></a><b><b>-o</b>, <b>--opaque-re</b>=<i>regular expression</i></b>
<p>Use "opaque" data type for the C types matched by the regular
expression, even if these types are <code class="inline"><span class="w">typedef</span></code>
-equivalent to types
from typemaps.  Should not be used without <b>-x</b>.</p>
<p>This may be useful since, say, types which are <code class="inline"><span class="w">typedef</span></code>
-equivalent
to integers may represent OS-related handles, and one may want to work
with these handles in OO-way, as in <code class="inline"><span class="i">$handle</span><span class="i">-&gt;do_something</span><span class="s">(</span><span class="s">)</span></code>
.
Use <code class="inline">-o .</code>
 if you want to handle all the <code class="inline"><span class="w">typedef</span></code>
ed types as opaque
types.</p>
<p>The type-to-match is whitewashed (except for commas, which have no
whitespace before them, and multiple <code class="inline"><span class="i">*</span></code>
 which have no whitespace
between them).</p>
</li>
<li><a name="*-p*%2c-*--remove-prefix*%3d_prefix_"></a><b><b>-p</b>, <b>--remove-prefix</b>=<i>prefix</i></b>
<p>Specify a prefix which should be removed from the Perl function names,
e.g., -p sec_rgy_ This sets up the XS <b>PREFIX</b> keyword and removes
the prefix from functions that are autoloaded via the <code class="inline"><span class="i">constant</span><span class="s">(</span><span class="s">)</span></code>

mechanism.</p>
</li>
<li><a name="*-s*%2c-*--const-subs*%3d_sub1%2csub2_"></a><b><b>-s</b>, <b>--const-subs</b>=<i>sub1,sub2</i></b>
<p>Create a perl subroutine for the specified macros rather than autoload
with the constant() subroutine.  These macros are assumed to have a
return type of <b>char *</b>, e.g.,
-s sec_rgy_wildcard_name,sec_rgy_wildcard_sid.</p>
</li>
<li><a name="*-t*%2c-*--default-type*%3d_type_"></a><b><b>-t</b>, <b>--default-type</b>=<i>type</i></b>
<p>Specify the internal type that the constant() mechanism uses for macros.
The default is IV (signed integer).  Currently all macros found during the
header scanning process will be assumed to have this type.  Future versions
of <code class="inline"><span class="w">h2xs</span></code>
 may gain the ability to make educated guesses.</p>
</li>
<li><a name="*--use-new-tests*"></a><b><b>--use-new-tests</b></b>
<p>When <b>--compat-version</b> (<b>-b</b>) is present the generated tests will use
<code class="inline"><span class="w">Test::More</span></code>
 rather than <code class="inline"><span class="w">Test</span></code>
 which is the default for versions before
5.6.2.  <code class="inline"><span class="w">Test::More</span></code>
 will be added to PREREQ_PM in the generated
<code class="inline"><span class="w">Makefile</span>.<span class="w">PL</span></code>
.</p>
</li>
<li><a name="*--use-old-tests*"></a><b><b>--use-old-tests</b></b>
<p>Will force the generation of test code that uses the older <code class="inline"><span class="w">Test</span></code>
 module.</p>
</li>
<li><a name="*--skip-exporter*"></a><b><b>--skip-exporter</b></b>
<p>Do not use <code class="inline"><span class="w">Exporter</span></code>
 and/or export any symbol.</p>
</li>
<li><a name="*--skip-ppport*"></a><b><b>--skip-ppport</b></b>
<p>Do not use <code class="inline"><span class="w">Devel::PPPort</span></code>
: no portability to older version.</p>
</li>
<li><a name="*--skip-autoloader*"></a><b><b>--skip-autoloader</b></b>
<p>Do not use the module <code class="inline"><span class="w">AutoLoader</span></code>
; but keep the constant() function
and <code class="inline"><a name="AUTOLOAD"></a>sub <span class="m">AUTOLOAD</span></code>
 for constants.</p>
</li>
<li><a name="*--skip-strict*"></a><b><b>--skip-strict</b></b>
<p>Do not use the pragma <code class="inline"><span class="w">strict</span></code>
.</p>
</li>
<li><a name="*--skip-warnings*"></a><b><b>--skip-warnings</b></b>
<p>Do not use the pragma <code class="inline"><span class="w">warnings</span></code>
.</p>
</li>
<li><a name="*-v*%2c-*--version*%3d_version_"></a><b><b>-v</b>, <b>--version</b>=<i>version</i></b>
<p>Specify a version number for this extension.  This version number is added
to the templates.  The default is 0.01, or 0.00_01 if <code class="inline">-B</code>
 is specified.
The version specified should be numeric.</p>
</li>
<li><a name="*-x*%2c-*--autogen-xsubs*"></a><b><b>-x</b>, <b>--autogen-xsubs</b></b>
<p>Automatically generate XSUBs basing on function declarations in the
header file.  The package <code class="inline"><span class="w">C::Scan</span></code>
 should be installed. If this
option is specified, the name of the header file may look like
<code class="inline"><span class="w">NAME1</span><span class="cm">,</span><span class="w">NAME2</span></code>
. In this case NAME1 is used instead of the specified
string, but XSUBs are emitted only for the declarations included from
file NAME2.</p>
<p>Note that some types of arguments/return-values for functions may
result in XSUB-declarations/typemap-entries which need
hand-editing. Such may be objects which cannot be converted from/to a
pointer (like <code class="inline"><span class="w">long</span> <span class="w">long</span></code>
), pointers to functions, or arrays.  See
also the section on <a href="#LIMITATIONS-of--x">LIMITATIONS of -x</a>.</p>
</li>
</ul>
<a name="EXAMPLES"></a><h1>EXAMPLES</h1>
<pre class="verbatim"><ol><li>    # Default behavior, extension is Rusers</li><li>    h2xs rpcsvc/rusers</li><li></li><li>    # Same, but extension is RUSERS</li><li>    h2xs -n RUSERS rpcsvc/rusers</li><li></li><li>    # Extension is rpcsvc::rusers. Still finds &lt;rpcsvc/rusers.h&gt;</li><li>    h2xs rpcsvc::rusers</li><li></li><li>    # Extension is ONC::RPC.  Still finds &lt;rpcsvc/rusers.h&gt;</li><li>    h2xs -n ONC::RPC rpcsvc/rusers</li><li></li><li>    # Without constant() or AUTOLOAD</li><li>    h2xs -c rpcsvc/rusers</li><li></li><li>    # Creates templates for an extension named RPC</li><li>    h2xs -cfn RPC</li><li></li><li>    # Extension is ONC::RPC.</li><li>    h2xs -cfn ONC::RPC</li><li></li><li>    # Extension is a pure Perl module with no XS code.</li><li>    h2xs -X My::Module</li><li></li><li>    # Extension is Lib::Foo which works at least with Perl5.005_03.</li><li>    # Constants are created for all #defines and enums h2xs can find</li><li>    # in foo.h.</li><li>    h2xs -b 5.5.3 -n Lib::Foo foo.h</li><li></li><li>    # Extension is Lib::Foo which works at least with Perl5.005_03.</li><li>    # Constants are created for all #defines but only for enums</li><li>    # whose names do not start with 'bar_'.</li><li>    h2xs -b 5.5.3 -e '^bar_' -n Lib::Foo foo.h</li><li></li><li>    # Makefile.PL will look for library -lrpc in</li><li>    # additional directory /opt/net/lib</li><li>    h2xs rpcsvc/rusers -L/opt/net/lib -lrpc</li><li></li><li>    # Extension is DCE::rgynbase</li><li>    # prefix "sec_rgy_" is dropped from perl function names</li><li>    h2xs -n DCE::rgynbase -p sec_rgy_ dce/rgynbase</li><li></li><li>    # Extension is DCE::rgynbase</li><li>    # prefix "sec_rgy_" is dropped from perl function names</li><li>    # subroutines are created for sec_rgy_wildcard_name and</li><li>    # sec_rgy_wildcard_sid</li><li>    h2xs -n DCE::rgynbase -p sec_rgy_ \</li><li>    -s sec_rgy_wildcard_name,sec_rgy_wildcard_sid dce/rgynbase</li><li></li><li>    # Make XS without defines in perl.h, but with function declarations</li><li>    # visible from perl.h. Name of the extension is perl1.</li><li>    # When scanning perl.h, define -DEXT=extern -DdEXT= -DINIT(x)=</li><li>    # Extra backslashes below because the string is passed to shell.</li><li>    # Note that a directory with perl header files would</li><li>    #  be added automatically to include path.</li><li>    h2xs -xAn perl1 -F "-DEXT=extern -DdEXT= -DINIT\(x\)=" perl.h</li><li></li><li>    # Same with function declaration in proto.h as visible from perl.h.</li><li>    h2xs -xAn perl2 perl.h,proto.h</li><li></li><li>    # Same but select only functions which match /^av_/</li><li>    h2xs -M '^av_' -xAn perl2 perl.h,proto.h</li><li></li><li>    # Same but treat SV* etc as "opaque" types</li><li>    h2xs -o '^[S]V \*$' -M '^av_' -xAn perl2 perl.h,proto.h</li></ol></pre><a name="Extension-based-on-_.h_-and-_.c_-files"></a><h2>Extension based on <i>.h</i> and <i>.c</i> files</h2>
<p>Suppose that you have some C files implementing some functionality,
and the corresponding header files.  How to create an extension which
makes this functionality accessible in Perl?  The example below
assumes that the header files are <i>interface_simple.h</i> and
<i>interface_hairy.h</i>, and you want the perl module be named as
<code class="inline"><span class="w">Ext::Ension</span></code>
.  If you need some preprocessor directives and/or
linking with external libraries, see the flags <code class="inline">-<span class="w">F</span></code>
, <code class="inline">-<span class="w">L</span></code>
 and <code class="inline">-l</code>

in <a href="#OPTIONS">OPTIONS</a>.</p>
<ul>
<li><a name="Find-the-directory-name"></a><b>Find the directory name</b>
<p>Start with a dummy run of h2xs:</p>
<pre class="verbatim"><ol><li>  <span class="w">h2xs</span> -<span class="w">Afn</span> <span class="w">Ext::Ension</span></li></ol></pre><p>The only purpose of this step is to create the needed directories, and
let you know the names of these directories.  From the output you can
see that the directory for the extension is <i>Ext/Ension</i>.</p>
</li>
<li><a name="Copy-C-files"></a><b>Copy C files</b>
<p>Copy your header files and C files to this directory <i>Ext/Ension</i>.</p>
</li>
<li><a name="Create-the-extension"></a><b>Create the extension</b>
<p>Run h2xs, overwriting older autogenerated files:</p>
<pre class="verbatim"><ol><li>  <span class="w">h2xs</span> -<span class="w">Oxan</span> <span class="w">Ext::Ension</span> <span class="w">interface_simple</span>.<span class="w">h</span> <span class="w">interface_hairy</span>.<span class="w">h</span></li></ol></pre><p>h2xs looks for header files <i>after</i> changing to the extension
directory, so it will find your header files OK.</p>
</li>
<li><a name="Archive-and-test"></a><b>Archive and test</b>
<p>As usual, run</p>
<pre class="verbatim"><ol><li>  <span class="w">cd</span> <span class="w">Ext</span>/<span class="w">Ension</span></li><li>  <span class="w">perl</span> <span class="w">Makefile</span>.<span class="w">PL</span></li><li>  <span class="w">make</span> <span class="w">dist</span></li><li>  <span class="w">make</span></li><li>  <span class="w">make</span> <span class="w">test</span></li></ol></pre></li>
<li><a name="Hints"></a><b>Hints</b>
<p>It is important to do <code class="inline"><span class="w">make</span> <span class="w">dist</span></code>
 as early as possible.  This way you
can easily merge(1) your changes to autogenerated files if you decide
to edit your <code class="inline">.h</code> files and rerun h2xs.</p>
<p>Do not forget to edit the documentation in the generated <i>.pm</i> file.</p>
<p>Consider the autogenerated files as skeletons only, you may invent
better interfaces than what h2xs could guess.</p>
<p>Consider this section as a guideline only, some other options of h2xs
may better suit your needs.</p>
</li>
</ul>
<a name="ENVIRONMENT"></a><h1>ENVIRONMENT</h1>
<p>No environment variables are used.</p>
<a name="AUTHOR"></a><h1>AUTHOR</h1>
<p>Larry Wall and others</p>
<a name="SEE-ALSO"></a><h1>SEE ALSO</h1>
<p><a href="perl.html">perl</a>, <a href="perlxstut.html">perlxstut</a>, <a href="ExtUtils/MakeMaker.html">ExtUtils::MakeMaker</a>, and <a href="AutoLoader.html">AutoLoader</a>.</p>
<a name="DIAGNOSTICS"></a><h1>DIAGNOSTICS</h1>
<p>The usual warnings if it cannot read or write the files involved.</p>
<a name="LIMITATIONS-of-*-x*"></a><h1>LIMITATIONS of <b>-x</b></h1>
<p><i>h2xs</i> would not distinguish whether an argument to a C function
which is of the form, say, <code class="inline"><a class="l_k" href="functions/int.html">int</a> <span class="i">*</span></code>
, is an input, output, or
input/output parameter.  In particular, argument declarations of the
form</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/int.html">int</a></li><li>    <span class="i">foo</span><span class="s">(</span><span class="w">n</span><span class="s">)</span></li><li>	<a class="l_k" href="functions/int.html">int</a> <span class="i">*n</span></li></ol></pre><p>should be better rewritten as</p>
<pre class="verbatim"><ol><li>    <a class="l_k" href="functions/int.html">int</a></li><li>    <span class="i">foo</span><span class="s">(</span><span class="w">n</span><span class="s">)</span></li><li>	<a class="l_k" href="functions/int.html">int</a> <span class="i">&amp;n</span></li></ol></pre><p>if <code class="inline"><span class="w">n</span></code>
 is an input parameter.</p>
<p>Additionally, <i>h2xs</i> has no facilities to intuit that a function</p>
<pre class="verbatim"><ol><li>   int</li><li>   foo(addr,l)</li><li>	char *addr</li><li>	int   l</li></ol></pre><p>takes a pair of address and length of data at this address, so it is better
to rewrite this function as</p>
<pre class="verbatim"><ol><li>    int</li><li>    foo(sv)</li><li>	    SV *addr</li><li>	PREINIT:</li><li>	    STRLEN len;</li><li>	    char *s;</li><li>	CODE:</li><li>	    s = SvPV(sv,len);</li><li>	    RETVAL = foo(s, len);</li><li>	OUTPUT:</li><li>	    RETVAL</li></ol></pre><p>or alternately</p>
<pre class="verbatim"><ol><li>    static int</li><li>    my_foo(SV *sv)</li><li>    {</li><li>	STRLEN len;</li><li>	char *s = SvPV(sv,len);</li><li></li><li>	return foo(s, len);</li><li>    }</li><li></li><li>    MODULE = foo	PACKAGE = foo	PREFIX = my_</li><li></li><li>    int</li><li>    foo(sv)</li><li>	SV *sv</li></ol></pre><p>See <a href="perlxs.html">perlxs</a> and <a href="perlxstut.html">perlxstut</a> for additional details.</p>




  <div id="page_index" class="hud_container">
    <div id="page_index_header" class="hud_header">
      <div id="page_index_close" class="hud_close"><a href="#" onClick="pageIndex.hide();return false;"></a></div>
      <div id="page_index_title" class="hud_title"><span class="hud_span_top">Page index</span></div>
      <div id="page_index_topright" class="hud_topright"></div>
    </div>
    <div id="page_index_content" class="hud_content">
      <ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#OPTIONS">OPTIONS</a><li><a href="#EXAMPLES">EXAMPLES</a><ul><li><a href="#Extension-based-on-_.h_-and-_.c_-files">Extension based on _.h_ and _.c_ files</a></ul><li><a href="#ENVIRONMENT">ENVIRONMENT</a><li><a href="#AUTHOR">AUTHOR</a><li><a href="#SEE-ALSO">SEE ALSO</a><li><a href="#DIAGNOSTICS">DIAGNOSTICS</a><li><a href="#LIMITATIONS-of-*-x*">LIMITATIONS of *-x*</a></ul>
    </div>
    <div id="page_index_footer" class="hud_footer">
      <div id="page_index_bottomleft" class="hud_bottomleft"></div>
      <div id="page_index_bottom" class="hud_bottom"><span class="hud_span_bottom"></span></div>
      <div id="page_index_resize" class="hud_resize"></div>
    </div>
  </div>


	    &nbsp;
          </div>
          <div id="content_footer">
          </div>
        </div>
        <div class="clear"></div>
      </div>
      
    <div id="footer">
      <div id="footer_content">
        <div id="footer_strapline">
          perldoc.perl.org - Official documentation for the Perl programming language
        </div>
        <div id="footer_links">
          <div id="address">
            <p class="name">Contact details</p>
            <p class="address">
	      Site maintained by <a href="mailto:jj@jonallen.info">Jon Allen (JJ)</a><br>
	    </p>
            <p class="contact">
              Documentation maintained by the <a href="http://lists.cpan.org/showlist.cgi?name=perl5-porters">Perl 5 Porters</a>
            </p>
          </div>
          <ul class="f1">
            <li>Manual
              <ul class="f2">
                <li><a href="index-overview.html">Overview</a>
                <li><a href="index-tutorials.html">Tutorials</a>
                <li><a href="index-faq.html">FAQs</a>
                <li><a href="index-history.html">Changes</a>
              </ul>
            <li>Reference
              <ul class="f2">
                <li><a href="index-language.html">Language</a>
                <li><a href="index-functions.html">Functions</a>
                <li><a href="perlop.html">Operators</a>
                <li><a href="perlvar.html">Variables</a>
              </ul>
            <li>Modules
              <ul class="f2">
                <li><a href="index-modules-A.html">Modules</a>
                <li><a href="index-pragmas.html">Pragmas</a>
                <li><a href="index-utilities.html">Utilities</a>
              </ul>
            <li>Misc
              <ul class="f2">
                <li><a href="index-licence.html">License</a>
                <li><a href="index-internals.html">Internals</a>
                <li><a href="index-platforms.html">Platforms</a>
              </ul>          </ul>
          <div class="clear"></div>
        </div>
      </div>
      <div id="footer_end">
      </div>
    </div>
      
    </div>
      <script language="JavaScript" type="text/javascript" src="static/exploreperl.js"></script>
      <script language="JavaScript" src="static/combined-20100403.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
  perldoc.setPath(0);
  perldoc.pageName    = 'h2xs';
  perldoc.pageAddress = 'h2xs.html';
  perldoc.contentPage = 1;
  explorePerl.render();
  explorePerl.addEvents('explore_anchor');
</script>
    
  </body>
</html>