1 ################################################################################
3 ## Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
4 ## Version 2.x, Copyright (C) 2001, Paul Marquess.
5 ## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
7 ## This program is free software; you can redistribute it and/or
8 ## modify it under the same terms as Perl itself.
10 ################################################################################
28 ppport.h - Perl/Pollution/Portability version __VERSION__
32 perl ppport.h [options] [source files]
34 Searches current directory for files if no [source files] are given
36 --help show short help
38 --version show version
40 --patch=file write one patch file with changes
41 --copy=suffix write changed copies with suffix
42 --diff=program use diff program and options
44 --compat-version=version provide compatibility with Perl version
45 --cplusplus accept C++ comments
47 --quiet don't output anything except fatal errors
48 --nodiag don't show diagnostics
49 --nohints don't show hints
50 --nochanges don't suggest changes
51 --nofilter don't filter input files
53 --strip strip all script and doc functionality
56 --list-provided list provided API
57 --list-unsupported list API that isn't supported all the way
59 --api-info=name show Perl API portability information
63 This version of F<ppport.h> is designed to support operation with Perl
64 installations back to __MIN_PERL__, and has been tested up to __MAX_PERL__.
70 Display a brief usage summary.
74 Display the version of F<ppport.h>.
76 =head2 --patch=I<file>
78 If this option is given, a single patch file will be created if
79 any changes are suggested. This requires a working diff program
80 to be installed on your system.
82 =head2 --copy=I<suffix>
84 If this option is given, a copy of each file will be saved with
85 the given suffix that contains the suggested changes. This does
86 not require any external programs. Note that this does not
87 automagically add a dot between the original filename and the
88 suffix. If you want the dot, you have to include it in the option
91 If neither C<--patch> or C<--copy> are given, the default is to
92 simply print the diffs for each file. This requires either
93 C<Text::Diff> or a C<diff> program to be installed.
95 =head2 --diff=I<program>
97 Manually set the diff program and options to use. The default
98 is to use C<Text::Diff>, when installed, and output unified
101 =head2 --compat-version=I<version>
103 Tell F<ppport.h> to check for compatibility with the given
104 Perl version. The default is to check for compatibility with Perl
105 version __MIN_PERL__. You can use this option to reduce the output
106 of F<ppport.h> if you intend to be backward compatible only
107 down to a certain Perl version.
111 Usually, F<ppport.h> will detect C++ style comments and
112 replace them with C style comments for portability reasons.
113 Using this option instructs F<ppport.h> to leave C++
118 Be quiet. Don't print anything except fatal errors.
122 Don't output any diagnostic messages. Only portability
123 alerts will be printed.
127 Don't output any hints. Hints often contain useful portability
128 notes. Warnings will still be displayed.
132 Don't suggest any changes. Only give diagnostic output and hints
133 unless these are also deactivated.
137 Don't filter the list of input files. By default, files not looking
138 like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
142 Strip all script and documentation functionality from F<ppport.h>.
143 This reduces the size of F<ppport.h> dramatically and may be useful
144 if you want to include F<ppport.h> in smaller modules without
145 increasing their distribution size too much.
147 The stripped F<ppport.h> will have a C<--unstrip> option that allows
148 you to undo the stripping, but only if an appropriate C<Devel::PPPort>
151 =head2 --list-provided
153 Lists the API elements for which compatibility is provided by
154 F<ppport.h>. Also lists if it must be explicitly requested,
155 if it has dependencies, and if there are hints or warnings for it.
157 =head2 --list-unsupported
159 Lists the API elements that are known not to be FULLY supported by F<ppport.h>,
160 and below which version of Perl they probably won't be available or work.
161 By FULLY, we mean that support isn't provided all the way back to the first
162 version of Perl that F<ppport.h> supports at all.
164 =head2 --api-info=I<name>
166 Show portability information for elements matching I<name>.
167 If I<name> is surrounded by slashes, it is interpreted as a regular
170 Normally, only API elements are shown, but if there are no matching API
171 elements but there are some other matching elements, those are shown. This
172 allows you to conveniently find when functions internal to the core
173 implementation were added; only people working on the core are likely to find
174 this last part useful.
178 In order for a Perl extension (XS) module to be as portable as possible
179 across differing versions of Perl itself, certain steps need to be taken.
185 Including this header is the first major one. This alone will give you
186 access to a large part of the Perl API that hasn't been available in
187 earlier Perl releases. Use
189 perl ppport.h --list-provided
191 to see which API elements are provided by ppport.h.
195 You should avoid using deprecated parts of the API. For example, using
196 global Perl variables without the C<PL_> prefix is deprecated. Also,
197 some API functions used to have a C<perl_> prefix. Using this form is
198 also deprecated. You can safely use the supported API, as F<ppport.h>
199 will provide wrappers for older Perl versions.
203 Although the purpose of F<ppport.h> is to keep you from having to concern
204 yourself with what version you are running under, there may arise instances
205 where you have to do so. These macros, the same ones as in base Perl, are
206 available to you in all versions, and are what you should use:
210 =item C<PERL_VERSION_I<xx>(major, minor, patch)>
212 Returns whether or not the perl currently being compiled has the specified
213 relationship I<xx> to the perl given by the parameters. I<xx> is one of
214 C<EQ>, C<NE>, C<LT>, C<LE>, C<GT>, C<GE>.
218 #if PERL_VERSION_GT(5,24,2)
219 code that will only be compiled on perls after v5.24.2
224 Note that this is usable in making compile-time decisions
226 You may use the special value '*' for the final number to mean ALL possible
229 #if PERL_VERSION_EQ(5,31,'*')
231 means all perls in the 5.31 series. And
233 #if PERL_VERSION_NE(5,24,'*')
235 means all perls EXCEPT 5.24 ones. And
237 #if PERL_VERSION_LE(5,9,'*')
241 #if PERL_VERSION_LT(5,10,0)
247 If you use one of a few functions or variables that were not present in
248 earlier versions of Perl, and that can't be provided using a macro, you
249 have to explicitly request support for these functions by adding one or
250 more C<#define>s in your source code before the inclusion of F<ppport.h>.
252 These functions or variables will be marked C<explicit> in the list shown
253 by C<--list-provided>.
255 Depending on whether you module has a single or multiple files that
256 use such functions or variables, you want either C<static> or global
259 For a C<static> function or variable (used only in a single source
262 #define NEED_function
263 #define NEED_variable
265 For a global function or variable (used in multiple source files),
268 #define NEED_function_GLOBAL
269 #define NEED_variable_GLOBAL
271 Note that you mustn't have more than one global request for the
272 same function or variable in your project.
276 To avoid namespace conflicts, you can change the namespace of the
277 explicitly exported functions / variables using the C<DPPP_NAMESPACE>
278 macro. Just C<#define> the macro before including C<ppport.h>:
280 #define DPPP_NAMESPACE MyOwnNamespace_
283 The default namespace is C<DPPP_>.
287 The good thing is that most of the above can be checked by running
288 F<ppport.h> on your source code. See the next section for
293 To verify whether F<ppport.h> is needed for your module, whether you
294 should make any changes to your code, and whether any special defines
295 should be used, F<ppport.h> can be run as a Perl script to check your
296 source code. Simply say:
300 The result will usually be a list of patches suggesting changes
301 that should at least be acceptable, if not necessarily the most
302 efficient solution, or a fix for all possible problems.
304 If you know that your XS module uses features only available in
305 newer Perl releases, if you're aware that it uses C++ comments,
306 and if you want all suggestions as a single patch file, you could
307 use something like this:
309 perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
311 If you only want your code to be scanned without any suggestions
314 perl ppport.h --nochanges
316 You can specify a different C<diff> program or options, using
317 the C<--diff> option:
319 perl ppport.h --diff='diff -C 10'
321 This would output context diffs with 10 lines of context.
323 If you want to create patched copies of your files instead, use:
325 perl ppport.h --copy=.new
327 To display portability information for the C<newSVpvn> function,
330 perl ppport.h --api-info=newSVpvn
332 Since the argument to C<--api-info> can be a regular expression,
335 perl ppport.h --api-info=/_nomg$/
337 to display portability information for all C<_nomg> functions or
339 perl ppport.h --api-info=/./
341 to display information for all known API elements.
345 Some of the suggested edits and/or generated patches may not compile as-is
346 without tweaking manually. This is generally due to the need for an extra
347 parameter to be added to the call to prevent buffer overflow.
349 If this version of F<ppport.h> is causing failure during
350 the compilation of this module, please check if newer versions
351 of either this module or C<Devel::PPPort> are available on CPAN
352 before sending a bug report.
354 If F<ppport.h> was generated using the latest version of
355 C<Devel::PPPort> and is causing failure of this module, please
356 file a bug report at L<https://github.com/Dual-Life/Devel-PPPort/issues>
358 Please include the following information:
364 The complete output from running "perl -V"
372 The name and version of the module you were trying to build.
376 A full log of the build that failed.
380 Any other information that you think could be relevant.
384 For the latest version of this code, please get the C<Devel::PPPort>
389 Version 3.x, Copyright (c) 2004-2013, Marcus Holland-Moritz.
391 Version 2.x, Copyright (C) 2001, Paul Marquess.
393 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
395 This program is free software; you can redistribute it and/or
396 modify it under the same terms as Perl itself.
400 See L<Devel::PPPort>.