Blame parts/inc/ppphdoc

Packit 7d6a7d
################################################################################
Packit 7d6a7d
##
Packit 7d6a7d
##  Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
Packit 7d6a7d
##  Version 2.x, Copyright (C) 2001, Paul Marquess.
Packit 7d6a7d
##  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
Packit 7d6a7d
##
Packit 7d6a7d
##  This program is free software; you can redistribute it and/or
Packit 7d6a7d
##  modify it under the same terms as Perl itself.
Packit 7d6a7d
##
Packit 7d6a7d
################################################################################
Packit 7d6a7d
Packit 7d6a7d
=provides
Packit 7d6a7d
Packit 7d6a7d
=dontwarn
Packit 7d6a7d
Packit 7d6a7d
NEED_function
Packit 7d6a7d
NEED_function_GLOBAL
Packit 7d6a7d
NEED_variable
Packit 7d6a7d
NEED_variable_GLOBAL
Packit 7d6a7d
DPPP_NAMESPACE
Packit 7d6a7d
Packit 7d6a7d
=implementation
Packit 7d6a7d
Packit 7d6a7d
=pod
Packit 7d6a7d
Packit 7d6a7d
=head1 NAME
Packit 7d6a7d
Packit 7d6a7d
ppport.h - Perl/Pollution/Portability version __VERSION__
Packit 7d6a7d
Packit 7d6a7d
=head1 SYNOPSIS
Packit 7d6a7d
Packit 7d6a7d
  perl ppport.h [options] [source files]
Packit 7d6a7d
Packit 7d6a7d
  Searches current directory for files if no [source files] are given
Packit 7d6a7d
Packit 7d6a7d
  --help                      show short help
Packit 7d6a7d
Packit 7d6a7d
  --version                   show version
Packit 7d6a7d
Packit 7d6a7d
  --patch=file                write one patch file with changes
Packit 7d6a7d
  --copy=suffix               write changed copies with suffix
Packit 7d6a7d
  --diff=program              use diff program and options
Packit 7d6a7d
Packit 7d6a7d
  --compat-version=version    provide compatibility with Perl version
Packit 7d6a7d
  --cplusplus                 accept C++ comments
Packit 7d6a7d
Packit 7d6a7d
  --quiet                     don't output anything except fatal errors
Packit 7d6a7d
  --nodiag                    don't show diagnostics
Packit 7d6a7d
  --nohints                   don't show hints
Packit 7d6a7d
  --nochanges                 don't suggest changes
Packit 7d6a7d
  --nofilter                  don't filter input files
Packit 7d6a7d
Packit 7d6a7d
  --strip                     strip all script and doc functionality from
Packit 7d6a7d
                              ppport.h
Packit 7d6a7d
Packit 7d6a7d
  --list-provided             list provided API
Packit 7d6a7d
  --list-unsupported          list unsupported API
Packit 7d6a7d
  --api-info=name             show Perl API portability information
Packit 7d6a7d
Packit 7d6a7d
=head1 COMPATIBILITY
Packit 7d6a7d
Packit 7d6a7d
This version of F<ppport.h> is designed to support operation with Perl
Packit 7d6a7d
installations back to __MIN_PERL__, and has been tested up to __MAX_PERL__.
Packit 7d6a7d
Packit 7d6a7d
=head1 OPTIONS
Packit 7d6a7d
Packit 7d6a7d
=head2 --help
Packit 7d6a7d
Packit 7d6a7d
Display a brief usage summary.
Packit 7d6a7d
Packit 7d6a7d
=head2 --version
Packit 7d6a7d
Packit 7d6a7d
Display the version of F<ppport.h>.
Packit 7d6a7d
Packit 7d6a7d
=head2 --patch=I<file>
Packit 7d6a7d
Packit 7d6a7d
If this option is given, a single patch file will be created if
Packit 7d6a7d
any changes are suggested. This requires a working diff program
Packit 7d6a7d
to be installed on your system.
Packit 7d6a7d
Packit 7d6a7d
=head2 --copy=I<suffix>
Packit 7d6a7d
Packit 7d6a7d
If this option is given, a copy of each file will be saved with
Packit 7d6a7d
the given suffix that contains the suggested changes. This does
Packit 7d6a7d
not require any external programs. Note that this does not
Packit 7d6a7d
automagically add a dot between the original filename and the
Packit 7d6a7d
suffix. If you want the dot, you have to include it in the option
Packit 7d6a7d
argument.
Packit 7d6a7d
Packit 7d6a7d
If neither C<--patch> or C<--copy> are given, the default is to
Packit 7d6a7d
simply print the diffs for each file. This requires either
Packit 7d6a7d
C<Text::Diff> or a C<diff> program to be installed.
Packit 7d6a7d
Packit 7d6a7d
=head2 --diff=I<program>
Packit 7d6a7d
Packit 7d6a7d
Manually set the diff program and options to use. The default
Packit 7d6a7d
is to use C<Text::Diff>, when installed, and output unified
Packit 7d6a7d
context diffs.
Packit 7d6a7d
Packit 7d6a7d
=head2 --compat-version=I<version>
Packit 7d6a7d
Packit 7d6a7d
Tell F<ppport.h> to check for compatibility with the given
Packit 7d6a7d
Perl version. The default is to check for compatibility with Perl
Packit 7d6a7d
version __MIN_PERL__. You can use this option to reduce the output
Packit 7d6a7d
of F<ppport.h> if you intend to be backward compatible only
Packit 7d6a7d
down to a certain Perl version.
Packit 7d6a7d
Packit 7d6a7d
=head2 --cplusplus
Packit 7d6a7d
Packit 7d6a7d
Usually, F<ppport.h> will detect C++ style comments and
Packit 7d6a7d
replace them with C style comments for portability reasons.
Packit 7d6a7d
Using this option instructs F<ppport.h> to leave C++
Packit 7d6a7d
comments untouched.
Packit 7d6a7d
Packit 7d6a7d
=head2 --quiet
Packit 7d6a7d
Packit 7d6a7d
Be quiet. Don't print anything except fatal errors.
Packit 7d6a7d
Packit 7d6a7d
=head2 --nodiag
Packit 7d6a7d
Packit 7d6a7d
Don't output any diagnostic messages. Only portability
Packit 7d6a7d
alerts will be printed.
Packit 7d6a7d
Packit 7d6a7d
=head2 --nohints
Packit 7d6a7d
Packit 7d6a7d
Don't output any hints. Hints often contain useful portability
Packit 7d6a7d
notes. Warnings will still be displayed.
Packit 7d6a7d
Packit 7d6a7d
=head2 --nochanges
Packit 7d6a7d
Packit 7d6a7d
Don't suggest any changes. Only give diagnostic output and hints
Packit 7d6a7d
unless these are also deactivated.
Packit 7d6a7d
Packit 7d6a7d
=head2 --nofilter
Packit 7d6a7d
Packit 7d6a7d
Don't filter the list of input files. By default, files not looking
Packit 7d6a7d
like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
Packit 7d6a7d
Packit 7d6a7d
=head2 --strip
Packit 7d6a7d
Packit 7d6a7d
Strip all script and documentation functionality from F<ppport.h>.
Packit 7d6a7d
This reduces the size of F<ppport.h> dramatically and may be useful
Packit 7d6a7d
if you want to include F<ppport.h> in smaller modules without
Packit 7d6a7d
increasing their distribution size too much.
Packit 7d6a7d
Packit 7d6a7d
The stripped F<ppport.h> will have a C<--unstrip> option that allows
Packit 7d6a7d
you to undo the stripping, but only if an appropriate C<Devel::PPPort>
Packit 7d6a7d
module is installed.
Packit 7d6a7d
Packit 7d6a7d
=head2 --list-provided
Packit 7d6a7d
Packit 7d6a7d
Lists the API elements for which compatibility is provided by
Packit 7d6a7d
F<ppport.h>. Also lists if it must be explicitly requested,
Packit 7d6a7d
if it has dependencies, and if there are hints or warnings for it.
Packit 7d6a7d
Packit 7d6a7d
=head2 --list-unsupported
Packit 7d6a7d
Packit 7d6a7d
Lists the API elements that are known not to be supported by
Packit 7d6a7d
F<ppport.h> and below which version of Perl they probably
Packit 7d6a7d
won't be available or work.
Packit 7d6a7d
Packit 7d6a7d
=head2 --api-info=I<name>
Packit 7d6a7d
Packit 7d6a7d
Show portability information for API elements matching I<name>.
Packit 7d6a7d
If I<name> is surrounded by slashes, it is interpreted as a regular
Packit 7d6a7d
expression.
Packit 7d6a7d
Packit 7d6a7d
=head1 DESCRIPTION
Packit 7d6a7d
Packit 7d6a7d
In order for a Perl extension (XS) module to be as portable as possible
Packit 7d6a7d
across differing versions of Perl itself, certain steps need to be taken.
Packit 7d6a7d
Packit 7d6a7d
=over 4
Packit 7d6a7d
Packit 7d6a7d
=item *
Packit 7d6a7d
Packit 7d6a7d
Including this header is the first major one. This alone will give you
Packit 7d6a7d
access to a large part of the Perl API that hasn't been available in
Packit 7d6a7d
earlier Perl releases. Use
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --list-provided
Packit 7d6a7d
Packit 7d6a7d
to see which API elements are provided by ppport.h.
Packit 7d6a7d
Packit 7d6a7d
=item *
Packit 7d6a7d
Packit 7d6a7d
You should avoid using deprecated parts of the API. For example, using
Packit 7d6a7d
global Perl variables without the C<PL_> prefix is deprecated. Also,
Packit 7d6a7d
some API functions used to have a C<perl_> prefix. Using this form is
Packit 7d6a7d
also deprecated. You can safely use the supported API, as F<ppport.h>
Packit 7d6a7d
will provide wrappers for older Perl versions.
Packit 7d6a7d
Packit 7d6a7d
=item *
Packit 7d6a7d
Packit 7d6a7d
If you use one of a few functions or variables that were not present in
Packit 7d6a7d
earlier versions of Perl, and that can't be provided using a macro, you
Packit 7d6a7d
have to explicitly request support for these functions by adding one or
Packit 7d6a7d
more C<#define>s in your source code before the inclusion of F<ppport.h>.
Packit 7d6a7d
Packit 7d6a7d
These functions or variables will be marked C<explicit> in the list shown
Packit 7d6a7d
by C<--list-provided>.
Packit 7d6a7d
Packit 7d6a7d
Depending on whether you module has a single or multiple files that
Packit 7d6a7d
use such functions or variables, you want either C<static> or global
Packit 7d6a7d
variants.
Packit 7d6a7d
Packit 7d6a7d
For a C<static> function or variable (used only in a single source
Packit 7d6a7d
file), use:
Packit 7d6a7d
Packit 7d6a7d
    #define NEED_function
Packit 7d6a7d
    #define NEED_variable
Packit 7d6a7d
Packit 7d6a7d
For a global function or variable (used in multiple source files),
Packit 7d6a7d
use:
Packit 7d6a7d
Packit 7d6a7d
    #define NEED_function_GLOBAL
Packit 7d6a7d
    #define NEED_variable_GLOBAL
Packit 7d6a7d
Packit 7d6a7d
Note that you mustn't have more than one global request for the
Packit 7d6a7d
same function or variable in your project.
Packit 7d6a7d
Packit 7d6a7d
    __EXPLICIT_API__
Packit 7d6a7d
Packit 7d6a7d
To avoid namespace conflicts, you can change the namespace of the
Packit 7d6a7d
explicitly exported functions / variables using the C<DPPP_NAMESPACE>
Packit 7d6a7d
macro. Just C<#define> the macro before including C<ppport.h>:
Packit 7d6a7d
Packit 7d6a7d
    #define DPPP_NAMESPACE MyOwnNamespace_
Packit 7d6a7d
    #include "ppport.h"
Packit 7d6a7d
Packit 7d6a7d
The default namespace is C<DPPP_>.
Packit 7d6a7d
Packit 7d6a7d
=back
Packit 7d6a7d
Packit 7d6a7d
The good thing is that most of the above can be checked by running
Packit 7d6a7d
F<ppport.h> on your source code. See the next section for
Packit 7d6a7d
details.
Packit 7d6a7d
Packit 7d6a7d
=head1 EXAMPLES
Packit 7d6a7d
Packit 7d6a7d
To verify whether F<ppport.h> is needed for your module, whether you
Packit 7d6a7d
should make any changes to your code, and whether any special defines
Packit 7d6a7d
should be used, F<ppport.h> can be run as a Perl script to check your
Packit 7d6a7d
source code. Simply say:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h
Packit 7d6a7d
Packit 7d6a7d
The result will usually be a list of patches suggesting changes
Packit 7d6a7d
that should at least be acceptable, if not necessarily the most
Packit 7d6a7d
efficient solution, or a fix for all possible problems.
Packit 7d6a7d
Packit 7d6a7d
If you know that your XS module uses features only available in
Packit 7d6a7d
newer Perl releases, if you're aware that it uses C++ comments,
Packit 7d6a7d
and if you want all suggestions as a single patch file, you could
Packit 7d6a7d
use something like this:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
Packit 7d6a7d
Packit 7d6a7d
If you only want your code to be scanned without any suggestions
Packit 7d6a7d
for changes, use:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --nochanges
Packit 7d6a7d
Packit 7d6a7d
You can specify a different C<diff> program or options, using
Packit 7d6a7d
the C<--diff> option:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --diff='diff -C 10'
Packit 7d6a7d
Packit 7d6a7d
This would output context diffs with 10 lines of context.
Packit 7d6a7d
Packit 7d6a7d
If you want to create patched copies of your files instead, use:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --copy=.new
Packit 7d6a7d
Packit 7d6a7d
To display portability information for the C<newSVpvn> function,
Packit 7d6a7d
use:
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --api-info=newSVpvn
Packit 7d6a7d
Packit 7d6a7d
Since the argument to C<--api-info> can be a regular expression,
Packit 7d6a7d
you can use
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --api-info=/_nomg$/
Packit 7d6a7d
Packit 7d6a7d
to display portability information for all C<_nomg> functions or
Packit 7d6a7d
Packit 7d6a7d
    perl ppport.h --api-info=/./
Packit 7d6a7d
Packit 7d6a7d
to display information for all known API elements.
Packit 7d6a7d
Packit 7d6a7d
=head1 BUGS
Packit 7d6a7d
Packit 7d6a7d
If this version of F<ppport.h> is causing failure during
Packit 7d6a7d
the compilation of this module, please check if newer versions
Packit 7d6a7d
of either this module or C<Devel::PPPort> are available on CPAN
Packit 7d6a7d
before sending a bug report.
Packit 7d6a7d
Packit 7d6a7d
If F<ppport.h> was generated using the latest version of
Packit 7d6a7d
C<Devel::PPPort> and is causing failure of this module, please
Packit 7d6a7d
file a bug report here: L<https://github.com/mhx/Devel-PPPort/issues/>
Packit 7d6a7d
Packit 7d6a7d
Please include the following information:
Packit 7d6a7d
Packit 7d6a7d
=over 4
Packit 7d6a7d
Packit 7d6a7d
=item 1.
Packit 7d6a7d
Packit 7d6a7d
The complete output from running "perl -V"
Packit 7d6a7d
Packit 7d6a7d
=item 2.
Packit 7d6a7d
Packit 7d6a7d
This file.
Packit 7d6a7d
Packit 7d6a7d
=item 3.
Packit 7d6a7d
Packit 7d6a7d
The name and version of the module you were trying to build.
Packit 7d6a7d
Packit 7d6a7d
=item 4.
Packit 7d6a7d
Packit 7d6a7d
A full log of the build that failed.
Packit 7d6a7d
Packit 7d6a7d
=item 5.
Packit 7d6a7d
Packit 7d6a7d
Any other information that you think could be relevant.
Packit 7d6a7d
Packit 7d6a7d
=back
Packit 7d6a7d
Packit 7d6a7d
For the latest version of this code, please get the C<Devel::PPPort>
Packit 7d6a7d
module from CPAN.
Packit 7d6a7d
Packit 7d6a7d
=head1 COPYRIGHT
Packit 7d6a7d
Packit 7d6a7d
Version 3.x, Copyright (c) 2004-2013, Marcus Holland-Moritz.
Packit 7d6a7d
Packit 7d6a7d
Version 2.x, Copyright (C) 2001, Paul Marquess.
Packit 7d6a7d
Packit 7d6a7d
Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
Packit 7d6a7d
Packit 7d6a7d
This program is free software; you can redistribute it and/or
Packit 7d6a7d
modify it under the same terms as Perl itself.
Packit 7d6a7d
Packit 7d6a7d
=head1 SEE ALSO
Packit 7d6a7d
Packit 7d6a7d
See L<Devel::PPPort>.
Packit 7d6a7d
Packit 7d6a7d
=cut