Skip to content
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

No static constructor is generated, though referenced, C compiler fails #97

Closed
cyborgyn opened this issue Oct 6, 2021 · 1 comment
Closed

Comments

@cyborgyn
Copy link

cyborgyn commented Oct 6, 2021

Consider the following case:

    class Program
    {
        static string category = "category";
    }

C code generated with a call to static constructor, which is not generated:

static struct Program_STATIC_FIELDS_DECL__ /* IL2C_STATIC_FIELDS */
{
    IL2C_STATIC_FIELDS* pNext__;
    const uint16_t objRefCount__;
    const uint16_t valueCount__;
    //-------------------- objref
    System_String* category;
} Program_STATIC_FIELDS__ = { NULL, 1, 0 };

System_String** Program_category_HANDLER__(void)
{
    if (il2c_unlikely__(Program_STATIC_FIELDS_initializerCount__ != *il2c_initializer_count))
    {
        Program_STATIC_FIELDS_initializerCount__ = *il2c_initializer_count;
        il2c_register_static_fields(&Program_STATIC_FIELDS__);
        Program__cctor();
    }
    return &Program_STATIC_FIELDS__.category;
}

Thus C compiler fails with Program__cctor(); is not declared.

@kekyo
Copy link
Owner

kekyo commented May 28, 2022

@cyborgyn Sorry for the very delay. I understood #100 work and imported it with cherry-pick. 2cbb6f1

Related #98

@kekyo kekyo closed this as completed May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants