New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed make test on ubuntu i386 and Mac OS X. #111
Conversation
When I run make test on ubuntu x86, or Mac OS X, it fails with the following errors: ``` g++ -Wall -c -O2 -std=c++11 -fpic -I"/home/andot/git/PHP-CPP/tests/include/lib" -I"/home/andot/git/PHP-CPP/tests/include/zts" -o main.o main.cpp In file included from h/variables.h:19:0, from main.cpp:13: h/../include/variables/011-012-value-casting-operators.h: In function ‘void TestVariables::value_casting(Php::Parameters&)’: h/../include/variables/011-012-value-casting-operators.h:23:17: error: conversion from ‘Php::Value’ to ‘long int’ is ambiguous long value1 = value; ^ h/../include/variables/011-012-value-casting-operators.h:21:14: note: candidates are: Php::Value value = params[0]; ^ In file included from /home/andot/git/PHP-CPP/tests/include/lib/phpcpp.h:36:0, from main.cpp:8: /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:659:5: note: Php::Value::operator double() const operator double () const ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:650:5: note: Php::Value::operator const char*() const <near match> operator const char * () const ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:650:5: note: no known conversion for implicit ‘this’ parameter from ‘const char*’ to ‘long int’ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:632:5: note: Php::Value::operator bool() const operator bool () const ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:623:5: note: Php::Value::operator int64_t() const operator int64_t () const ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:614:5: note: Php::Value::operator int32_t() const operator int32_t () const ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:605:5: note: Php::Value::operator int16_t() const operator int16_t () const ^ In file included from /home/andot/git/PHP-CPP/tests/include/lib/phpcpp.h:59:0, from main.cpp:8: /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/class.h: In instantiation of ‘Php::Value Php::Class<ANYTHING>::callToInteger(Php::Base*) const [with T = TestVariables::Obj2Scalar]’: main.cpp:179:1: required from here /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/class.h:450:63: error: call of overloaded ‘Value(long int)’ is ambiguous return Value(obj->__toInteger()).setType(Type::Numeric); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/class.h:450:63: note: candidates are: In file included from /home/andot/git/PHP-CPP/tests/include/lib/phpcpp.h:36:0, from main.cpp:8: /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:133:5: note: Php::Value::Value(Php::Value&&) Value(Value &&that); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:127:5: note: Php::Value::Value(const Php::Value&) Value(const Value &that); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:121:5: note: Php::Value::Value(const Php::Base*) <near match> Value(const Base *base); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:121:5: note: no known conversion for argument 1 from ‘long int’ to ‘const Php::Base*’ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:115:5: note: Php::Value::Value(_zval_struct*, bool) <near match> Value(struct _zval_struct *zval, bool ref=false); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:115:5: note: no known conversion for argument 1 from ‘long int’ to ‘_zval_struct*’ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:61:5: note: Php::Value::Value(double) Value(double value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:60:5: note: Php::Value::Value(const char*, int) <near match> Value(const char *value, int size = -1); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:60:5: note: no known conversion for argument 1 from ‘long int’ to ‘const char*’ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:59:5: note: Php::Value::Value(const string&) <near match> Value(const std::string &value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:59:5: note: no known conversion for argument 1 from ‘long int’ to ‘const string& {aka const std::basic_string<char>&}’ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:58:5: note: Php::Value::Value(char) Value(char value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:57:5: note: Php::Value::Value(bool) Value(bool value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:56:5: note: Php::Value::Value(int64_t) Value(int64_t value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:55:5: note: Php::Value::Value(int32_t) Value(int32_t value); ^ /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/value.h:54:5: note: Php::Value::Value(int16_t) Value(int16_t value); ^ In file included from /home/andot/git/PHP-CPP/tests/include/lib/phpcpp.h:59:0, from main.cpp:8: /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/class.h: In member function ‘Php::Value Php::Class<ANYTHING>::callToInteger(Php::Base*) const [with T = TestVariables::Obj2Scalar]’: /home/andot/git/PHP-CPP/tests/include/lib/phpcpp/class.h:451:5: warning: control reaches end of non-void function [-Wreturn-type] } ^ ``` This patch fixed it.
The problem here is that al the 'intNN_t' and 'uintNN_t' types are guaranteed to be of the right size, unlike types like 'long long', 'long', et cetera. In fact, if I remember correctly, on some platforms 'long long' and 'long' could even be identical, leading to compile errors. PHP internally uses 'long' for numbers, which has a different size on different platforms. I have the impression that this is a fundamental problem of PHP, and not of PHP-CPP. |
In fact, if I remember correctly, 'long long' and 'long' are treated as different types in C++ even if the size of them are the same. So if you used |
Unfortunately the test framework was removed, so this pull request is no longer relevant. |
When I run make test on ubuntu x86, or Mac OS X, it fails with the
following errors:
This patch fixed it.