Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

in window no error ,in centos 7 64 has error: undefined Call function my_get_host

in window no error ,in centos 7 64 has error: undefined Call function mygethost.

the window php 5.6 ts, the centos 7 64 php5.6 nts.

Zephir version 0.9.4a-dev-1e1c234ef0

I think the code “mygethost” as a PHP function to call, not as a function of the C language, so it can not find. I don't knows the solution.

the "mygethost" is my optimizers

the config.json

"extra-sources": [ "my/my.c" ],

the code:

#ifdef HAVE_CONFIG_H
#include "../ext_config.h"
#endif

#include <php.h>
#include "../php_ext.h"
#include "../ext.h"

#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>



#include "kernel/main.h"
#include "kernel/memory.h"
#include "kernel/fcall.h"
#include "kernel/operators.h"
#include "kernel/exception.h"
#include "kernel/concat.h"
#include "ext/spl/spl_exceptions.h"
#include "kernel/array.h"
#include "kernel/string.h"
#include "kernel/object.h"
#include "kernel/hash.h"
void my_get_host(zval *return_value TSRMLS_DC)
{
    ZVAL_STRING(return_value,"my_test",1);
}

the optimizers

    namespace Zephir\Optimizers\FunctionCall;

use Zephir\Call;
use Zephir\CompilerException;
use Zephir\CompilationContext;
use Zephir\CompiledExpression;
use Zephir\Optimizers\OptimizerAbstract;

class MyGetHostOptimizer extends OptimizerAbstract
{

    public function optimize(array $expression, Call $call, CompilationContext $context)
    {

        $call->processExpectedReturn($context);
        $symbolVariable = $call->getSymbolVariable(true, $context);
        if ($symbolVariable->isNotVariableAndString()) {
            throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
        }
        $symbolVariable->setDynamicTypes('string');

        if ($call->mustInitSymbolVariable()) {
            $symbolVariable->initVariant($context);
        }
        $symbol = $context->backend->getVariableCode($symbolVariable);
        $context->codePrinter->output('my_get_host(' . $symbol . ' TSRMLS_CC);');

        return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
    }

}


4.5k
Accepted
answer

I think it is a function of the prefix “my" and the module name "my", causing the conflict,

I modify the function of the prefix after the problem is solved.