Compatible to clang.

This commit is contained in:
CismonX 2019-07-13 00:29:03 +08:00
parent 2c0c89bff7
commit cfed6ca160
5 changed files with 57 additions and 48 deletions

View File

@ -6,7 +6,12 @@ PHP_ARG_ENABLE(arma-operators, for operator overloading support in armadillo,
if test "$PHP_ARMA" != "no"; then
PHP_REQUIRE_CXX()
EXTRA_CXXFLAGS="-std=c++17 -Wno-undefined-var-template"
EXTRA_CXXFLAGS="-std=c++17"
CLANG_TEST_STR=`$CXX -v | grep clang`
if test CLANG_TEST_STR != ""; then
EXTRA_CXXFLAGS+=" -Wno-undefined-var-template -Wno-deprecated-declarations"
fi
OPERATORS_SRC="src/operators.cc"
ARMA_SRC=`ls -1d src/*.cc | grep -v $OPERATORS_SRC`

View File

@ -22,41 +22,41 @@ namespace php_arma
void constants_init()
{
const_declare(fill_ce = abstract_class_register<fill_php_name>(),
std::tuple("NONE", fill::none),
std::tuple("ZEROS", fill::zeros),
std::tuple("ONES", fill::ones),
std::tuple("EYE", fill::eye),
std::tuple("RANDU", fill::randu),
std::tuple("RANDN", fill::randn)
std::make_tuple("NONE", fill::none),
std::make_tuple("ZEROS", fill::zeros),
std::make_tuple("ONES", fill::ones),
std::make_tuple("EYE", fill::eye),
std::make_tuple("RANDU", fill::randu),
std::make_tuple("RANDN", fill::randn)
);
const_declare(file_type_ce = abstract_class_register<file_type_php_name>(),
std::tuple("AUTO_DETECT", file_type::auto_detect),
std::tuple("ARMA_BINARY", file_type::arma_binary),
std::tuple("ARMA_ASCII", file_type::arma_ascii),
std::tuple("RAW_BINARY", file_type::raw_binary),
std::tuple("RAW_ASCII", file_type::raw_ascii),
std::tuple("CSV_ASCII", file_type::csv_ascii),
std::tuple("COORD_ASCII", file_type::coord_ascii),
std::tuple("PGM_BINARY", file_type::pgm_binary),
std::tuple("HDF5_BINARY", file_type::hdf5_binary)
std::make_tuple("AUTO_DETECT", file_type::auto_detect),
std::make_tuple("ARMA_BINARY", file_type::arma_binary),
std::make_tuple("ARMA_ASCII", file_type::arma_ascii),
std::make_tuple("RAW_BINARY", file_type::raw_binary),
std::make_tuple("RAW_ASCII", file_type::raw_ascii),
std::make_tuple("CSV_ASCII", file_type::csv_ascii),
std::make_tuple("COORD_ASCII", file_type::coord_ascii),
std::make_tuple("PGM_BINARY", file_type::pgm_binary),
std::make_tuple("HDF5_BINARY", file_type::hdf5_binary)
);
const_declare(sort_direction_ce = abstract_class_register<sort_direction_php_name>(),
std::tuple("ASCEND", sort_direction::ascend),
std::tuple("DESCEND", sort_direction::descend),
std::tuple("STRICT_ASCEND", sort_direction::strict_ascend),
std::tuple("STRICT_DESCEND", sort_direction::strict_descend)
std::make_tuple("ASCEND", sort_direction::ascend),
std::make_tuple("DESCEND", sort_direction::descend),
std::make_tuple("STRICT_ASCEND", sort_direction::strict_ascend),
std::make_tuple("STRICT_DESCEND", sort_direction::strict_descend)
);
#ifdef ARMA_USE_HDF5
const_declare(hdf5_opts_ce = abstract_class_register<hdf5_opts_php_name>(),
std::tuple("NONE", hdf5_opts::none),
std::tuple("TRANS", hdf5_opts::trans),
std::tuple("APPEND", hdf5_opts::append),
std::tuple("REPLACE", hdf5_opts::replace)
std::make_tuple("NONE", hdf5_opts::none),
std::make_tuple("TRANS", hdf5_opts::trans),
std::make_tuple("APPEND", hdf5_opts::append),
std::make_tuple("REPLACE", hdf5_opts::replace)
);
#endif // ARMA_USE_HDF5
const_declare(features_ce = abstract_class_register<features_php_name>(),
std::tuple("OPERATORS", features::operators),
std::tuple("HDF5", features::hdf5)
std::make_tuple("OPERATORS", features::operators),
std::make_tuple("HDF5", features::hdf5)
);
}
}

View File

@ -234,21 +234,21 @@ namespace php_arma
void operators_init()
{
set_op_handlers(
std::tuple(ZEND_ADD, add_handler),
std::tuple(ZEND_ASSIGN_ADD, add_assign_handler),
std::tuple(ZEND_SUB, sub_handler),
std::tuple(ZEND_ASSIGN_SUB, sub_assign_handler),
std::tuple(ZEND_MUL, mul_handler),
std::tuple(ZEND_ASSIGN_MUL, mul_assign_handler),
std::tuple(ZEND_DIV, div_handler),
std::tuple(ZEND_ASSIGN_DIV, div_assign_handler),
std::tuple(ZEND_POW, pow_handler),
std::tuple(ZEND_ASSIGN_POW, pow_assign_handler),
std::tuple(ZEND_BW_NOT, bw_not_handler),
std::tuple(ZEND_IS_EQUAL, is_equal_handler),
std::tuple(ZEND_IS_NOT_EQUAL, is_not_equal_handler),
std::tuple(ZEND_IS_SMALLER, is_smaller_handler),
std::tuple(ZEND_IS_SMALLER_OR_EQUAL, is_smaller_or_equal_handler)
std::make_tuple(ZEND_ADD, add_handler),
std::make_tuple(ZEND_ASSIGN_ADD, add_assign_handler),
std::make_tuple(ZEND_SUB, sub_handler),
std::make_tuple(ZEND_ASSIGN_SUB, sub_assign_handler),
std::make_tuple(ZEND_MUL, mul_handler),
std::make_tuple(ZEND_ASSIGN_MUL, mul_assign_handler),
std::make_tuple(ZEND_DIV, div_handler),
std::make_tuple(ZEND_ASSIGN_DIV, div_assign_handler),
std::make_tuple(ZEND_POW, pow_handler),
std::make_tuple(ZEND_ASSIGN_POW, pow_assign_handler),
std::make_tuple(ZEND_BW_NOT, bw_not_handler),
std::make_tuple(ZEND_IS_EQUAL, is_equal_handler),
std::make_tuple(ZEND_IS_NOT_EQUAL, is_not_equal_handler),
std::make_tuple(ZEND_IS_SMALLER, is_smaller_handler),
std::make_tuple(ZEND_IS_SMALLER_OR_EQUAL, is_smaller_or_equal_handler)
);
}
}

View File

@ -40,7 +40,7 @@
void ZEND_FASTCALL cls<__VA_ARGS__>::zif_##func(INTERNAL_FUNCTION_PARAMETERS)
#define PHP_ARMA_FENTRY(fentry) \
std::tuple(fentry_size(fentry), fentry)
std::make_tuple(fentry_size(fentry), fentry)
#define PHP_ARMA_INSTANTIATE(parent, child) \
template class parent<double, child<double>>; \

View File

@ -9,7 +9,7 @@
#include "php_arma.hh"
#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#include <ext/stdio_filebuf.h>
@ -23,14 +23,18 @@
#else
#define Z_ISTREAM_P(zval_p, name) zval_to_iostream_unsupported()
#define Z_OSTREAM_P(zval_p, name) zval_to_iostream_unsupported()
#define Z_ISTREAM_P(zval_p, name) \
extern std::istream name; \
zval_to_iostream_unsupported()
#define Z_OSTREAM_P(zval_p, name) \
extern std::ostream name; \
zval_to_iostream_unsupported()
#endif // __GNUC__
#endif
namespace php_arma
{
#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
zend_always_inline
int zval_to_fd(zval *zv)
{
@ -56,7 +60,7 @@ namespace php_arma
}
constexpr auto zval_to_iostream_supported = false;
#endif // __GNUC__
#endif
}
#endif // !PHP_ARMA_STREAM_UTILS_HH