Skip to content

Commit a3eed5f

Browse files
committed
Move __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defs earlier
These defines should apply to windows as well, so move them out of the non-windows specific section and always define them for C++ compilations.
1 parent 5ece3ec commit a3eed5f

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

main/php_stdint.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@
1919
#ifndef PHP_STDINT_H
2020
#define PHP_STDINT_H
2121

22+
/* C99 requires these for C++ to get the definitions
23+
* of INT64_MAX and other macros used by Zend/zend_long.h
24+
* C11 drops this requirement, so these effectively
25+
* just backport that piece of behavior.
26+
*
27+
* These defines are placed here instead of
28+
* with the include below, because sys/types
29+
* and inttypes may include stdint themselves.
30+
* And these definitions MUST come first.
31+
*/
32+
#ifdef __cplusplus
33+
# ifndef __STDC_LIMIT_MACROS
34+
# define __STDC_LIMIT_MACROS
35+
# endif
36+
# ifndef __STDC_CONSTANT_MACROS
37+
# define __STDC_CONSTANT_MACROS
38+
# endif
39+
#endif
40+
2241
#if defined(_MSC_VER)
2342
/* Make sure the regular stdint.h wasn't included already and prevent it to be
2443
included afterwards. Though if some other library needs some stuff from
@@ -42,21 +61,6 @@
4261

4362
#include "php_config.h"
4463

45-
#if HAVE_STDINT_H && defined(__cplusplus)
46-
/* C99 requires these for C++ to get the definitions
47-
* of INT64_MAX and other macros used by Zend/zend_long.h
48-
* C11 drops this requirement, so these effectively
49-
* just backport that piece of behavior.
50-
*
51-
* These defines are placed here instead of
52-
* with the include below, because sys/types
53-
* and inttypes may include stdint themselves.
54-
* And these definitions MUST come first.
55-
*/
56-
# define __STDC_LIMIT_MACROS
57-
# define __STDC_CONSTANT_MACROS
58-
#endif
59-
6064
#if HAVE_SYS_TYPES_H
6165
# include <sys/types.h>
6266
#endif

0 commit comments

Comments
 (0)