This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Protect against ptrdiff_t not being available.
authorH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Tue, 15 Jul 2014 12:29:23 +0000 (14:29 +0200)
committerH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Tue, 15 Jul 2014 12:29:23 +0000 (14:29 +0200)
This is primarily for pedantic builds; ptrdiff_t is now standard,
and had already been in use in the core without guards.

Backport of d0b86e2f7c43ab4fc0721d279c46624052695726
Brian Fraser <fraserbn@gmail.com>  2014-05-31 01:10:20

U/perl/d_ptrdiff_t.U [new file with mode: 0644]

diff --git a/U/perl/d_ptrdiff_t.U b/U/perl/d_ptrdiff_t.U
new file mode 100644 (file)
index 0000000..4f230e8
--- /dev/null
@@ -0,0 +1,37 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 2014 H.Merijn Brand
+?RCS:
+?RCS: You may distribute under the terms of either the GNU General Public
+?RCS: License or the Artistic License, as specified in the README file.
+?RCS:
+?MAKE:d_ptrdiff_t: Inlibc Setvar Compile rm_try cat
+?MAKE: -pick add $@ %<
+?S:d_ptrdiff_t:
+?S:    This symbol will be defined if the C compiler supports ptrdiff_t.
+?S:.
+?C:HAS_PTRDIFF_T:
+?C:    This symbol will be defined if the C compiler supports ptrdiff_t.
+?C:.
+?H:#$d_ptrdiff_t       HAS_PTRDIFF_T                   /**/
+?H:.
+?LINT:set d_ptrdiff_t
+: check for ptrdiff_t
+echo " "
+echo "Checking to see if you have ptrdiff_t..." >&4
+$cat >try.c <<EOCP
+#include <stddef.h>
+int main() { ptrdiff_t x = 7; }
+EOCP
+set try
+if eval $compile; then
+       val="$define"
+       echo "You have ptrdiff_t."
+else
+       val="$undef"
+       echo "You do not have ptrdiff_t."
+fi
+$rm_try
+set d_ptrdiff_t
+eval $setvar
+