Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7ba7986

Browse files
committed
Fix interaction of Perl and stdbool.h
Revert the PL/Perl-specific change in 9a95a77. 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.
1 parent f1a074b commit 7ba7986

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/include/c.h

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268

269269
#if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
270270
#include <stdbool.h>
271+
#define USE_STDBOOL 1
271272
#else
272273

273274
#ifndef bool

src/pl/plperl/plperl.h

+13-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
#define __inline__ inline
5151
#endif
5252

53-
/*
54-
* Prevent perl from redefining "bool".
55-
*/
56-
#define HAS_BOOL 1
57-
5853

5954
/*
6055
* Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code
@@ -96,6 +91,19 @@
9691
#define NEED_sv_2pv_flags
9792
#include "ppport.h"
9893

94+
/*
95+
* perl might have included stdbool.h. If we also did that earlier (see c.h),
96+
* then that's fine. If not, we probably rejected it for some reason. In
97+
* that case, undef bool and proceed with our own bool. (Note that stdbool.h
98+
* makes bool a macro, but our own replacement is a typedef, so the undef
99+
* makes ours visible again).
100+
*/
101+
#ifndef USE_STDBOOL
102+
#ifdef bool
103+
#undef bool
104+
#endif
105+
#endif
106+
99107
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
100108
#ifndef HeUTF8
101109
#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \

0 commit comments

Comments
 (0)