Commit 7ba7986f authored by Peter Eisentraut's avatar Peter Eisentraut

Fix interaction of Perl and stdbool.h

Revert the PL/Perl-specific change in
9a95a77d.  We must not prevent Perl from
using stdbool.h when it has been built to do so, even if it uses an
incompatible size.  Otherwise, we would be imposing our bool on Perl,
which will lead to crashes because of the size mismatch.

Instead, we undef bool after including the Perl headers, as we did
previously, but now only if we are not using stdbool.h ourselves.
Record that choice in c.h as USE_STDBOOL.  This will also make it easier
to apply that coding pattern elsewhere if necessary.
parent f1a074b1
......@@ -268,6 +268,7 @@
#if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
#include <stdbool.h>
#define USE_STDBOOL 1
#else
#ifndef bool
......
......@@ -50,11 +50,6 @@
#define __inline__ inline
#endif
/*
* Prevent perl from redefining "bool".
*/
#define HAS_BOOL 1
/*
* Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code
......@@ -96,6 +91,19 @@
#define NEED_sv_2pv_flags
#include "ppport.h"
/*
* perl might have included stdbool.h. If we also did that earlier (see c.h),
* then that's fine. If not, we probably rejected it for some reason. In
* that case, undef bool and proceed with our own bool. (Note that stdbool.h
* makes bool a macro, but our own replacement is a typedef, so the undef
* makes ours visible again).
*/
#ifndef USE_STDBOOL
#ifdef bool
#undef bool
#endif
#endif
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
#ifndef HeUTF8
#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment