November 19, 2003
The following code works when copiled with debugging information but fails if compiled with optimizations turned on. An "Error: Access Violation" is thrown at the php_embed_init() call.


const int SUCCESS = 0;

extern (C)
{
    int php_embed_init(int argc, char **argv , void ****ptsrm_ls);
    void php_embed_shutdown(void ***tsrm_ls);

    export char* get_zend_version();
}


int main()
{
    static char *argv[2] = ["test1", null];
    void*** tsrm_ls = null;

    if (SUCCESS != php_embed_init(1, argv, &tsrm_ls))
    {
        printf("Failed initializing php_embed sapi\n");
        return -1;
    }

    printf("Zend version: %s\n", get_zend_version());

    php_embed_shutdown(tsrm_ls);
    return 0;
}


The php_embed_init() and php_embed_shutdown() are stored in the
php4embed.lib and get_zend_version() is on the DLL. Also, I'm sure that
tsrm_ls is initialized inside php_embed_init() before using it.

Does anyone see what would the problem be?


--
Julio César Carrascal Urquijo
http://www.artelogico.com/



November 21, 2003
You could try obj2asm'ing the .obj files and seeing if anything looks wrong.

"Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:bph021$1slg$1@digitaldaemon.com...
> The following code works when copiled with debugging information but fails if compiled with optimizations turned on. An "Error: Access Violation" is thrown at the php_embed_init() call.
>
>
> const int SUCCESS = 0;
>
> extern (C)
> {
>     int php_embed_init(int argc, char **argv , void ****ptsrm_ls);
>     void php_embed_shutdown(void ***tsrm_ls);
>
>     export char* get_zend_version();
> }
>
>
> int main()
> {
>     static char *argv[2] = ["test1", null];
>     void*** tsrm_ls = null;
>
>     if (SUCCESS != php_embed_init(1, argv, &tsrm_ls))
>     {
>         printf("Failed initializing php_embed sapi\n");
>         return -1;
>     }
>
>     printf("Zend version: %s\n", get_zend_version());
>
>     php_embed_shutdown(tsrm_ls);
>     return 0;
> }
>
>
> The php_embed_init() and php_embed_shutdown() are stored in the
> php4embed.lib and get_zend_version() is on the DLL. Also, I'm sure that
> tsrm_ls is initialized inside php_embed_init() before using it.
>
> Does anyone see what would the problem be?
>
>
> --
> Julio César Carrascal Urquijo
> http://www.artelogico.com/
>
>
>