jbboehr / php-mustache

Mustache PHP Extension
MIT License
56 stars 22 forks source link

Error when building #31

Closed amcnea closed 7 years ago

amcnea commented 7 years ago

When trying to build this package on CentOS 6, I received the following error message:

/repos/php-mustache/mustache_data.cpp: In function ‘void mustache_data_from_zval(mustache::Data*, zval*)’:
/repos/php-mustache/mustache_data.cpp:581: error: call of overloaded ‘to_string(long int&)’ is ambiguous

I ended up type casting the offending item as shown in the diff below.

diff --git a/mustache_data.cpp b/mustache_data.cpp
index f9c09d1..4df6a02 100644
--- a/mustache_data.cpp
+++ b/mustache_data.cpp
@@ -572,7 +572,7 @@ void mustache_data_from_zval(mustache::Data * node, zval * current TSRMLS_DC)
           break;
       case IS_LONG:
           node->type = mustache::Data::TypeString;
-          node->val = new std::string(std::to_string(Z_LVAL_P(current)));
+          node->val = new std::string(std::to_string((long long)Z_LVAL_P(current)));
           break;
 #if PHP_MAJOR_VERSION < 7
       case IS_BOOL:

The make test passed

jbboehr commented 7 years ago

Thanks!