Skip to content

Commit 128a3b6

Browse files
Fix compile issues on icu62 and lower
1 parent aee4911 commit 128a3b6

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

ext/intl/rangeformatter/rangeformatter_class.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212
+----------------------------------------------------------------------+
1313
*/
1414

15+
extern "C" {
16+
#include "php.h"
17+
#include "zend_API.h"
18+
#include "../intl_common.h"
19+
}
20+
21+
#if U_ICU_VERSION_MAJOR_NUM >= 63
1522
#include <unicode/numberrangeformatter.h>
1623
#include <unicode/unumberrangeformatter.h>
1724
#include <unicode/numberformatter.h>
1825
#include <unicode/unistr.h>
1926
#include "../intl_convertcpp.h"
27+
#endif
2028

2129
extern "C" {
22-
#include "php.h"
23-
#include "zend_API.h"
24-
#include "../intl_common.h"
2530
#include "../intl_error.h"
2631
#include "../php_intl.h"
2732
#include "../intl_data.h"
@@ -30,12 +35,14 @@ extern "C" {
3035
#include "intl_convert.h"
3136
}
3237

38+
#if U_ICU_VERSION_MAJOR_NUM >= 63
3339
using icu::number::NumberRangeFormatter;
3440
using icu::number::NumberFormatter;
3541
using icu::number::UnlocalizedNumberFormatter;
3642
using icu::number::LocalizedNumberRangeFormatter;
3743
using icu::UnicodeString;
3844
using icu::MeasureUnit;
45+
#endif
3946

4047
static zend_object_handlers rangeformatter_handlers;
4148
zend_class_entry *class_entry_IntlNumberRangeFormatter;
@@ -68,8 +75,7 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
6875
#if U_ICU_VERSION_MAJOR_NUM < 63
6976
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
7077
RETURN_THROWS();
71-
#endif
72-
78+
#else
7379
char* skeleton;
7480
char* locale;
7581
size_t locale_len;
@@ -133,10 +139,15 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton)
133139
RANGEFORMATTER_OBJECT(php_intl_numberrangeformatter_fetch_object(obj)) = nrf;
134140

135141
RETURN_OBJ(obj);
142+
#endif
136143
}
137144

138145
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
139146
{
147+
#if U_ICU_VERSION_MAJOR_NUM < 63
148+
zend_throw_error(NULL, "IntlNumberRangeFormatter is not available in ICU 62 and earlier");
149+
RETURN_THROWS();
150+
#else
140151
zval *start;
141152
zval *end;
142153

@@ -169,6 +180,7 @@ U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format)
169180
}
170181

171182
RETVAL_NEW_STR(ret);
183+
#endif
172184
}
173185

174186
U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, getErrorCode)

ext/intl/rangeformatter/rangeformatter_class.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@
1515
#ifndef RANGEFORMATTER_CLASS_H
1616
#define RANGEFORMATTER_CLASS_H
1717

18+
#if U_ICU_VERSION_MAJOR_NUM >= 63
1819
#include <unicode/numberrangeformatter.h>
1920

2021
#ifdef __cplusplus
2122
using icu::number::LocalizedNumberRangeFormatter;
2223
#else
2324
typedef void LocalizedNumberRangeFormatter;
2425
#endif
26+
#endif // U_ICU_VERSION_MAJOR_NUM >= 63
2527

2628
typedef struct {
2729
// error handling
2830
intl_error error;
2931

3032
// formatter handling
33+
#if U_ICU_VERSION_MAJOR_NUM >= 63
3134
LocalizedNumberRangeFormatter* unumrf;
35+
#else
36+
void* unumrf;
37+
#endif
3238
} rangeformatter_data;
3339

3440
typedef struct {

0 commit comments

Comments
 (0)