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

Extern function fails to resolve #2166

Open
Grimelios opened this issue Feb 25, 2025 · 0 comments
Open

Extern function fails to resolve #2166

Grimelios opened this issue Feb 25, 2025 · 0 comments

Comments

@Grimelios
Copy link

Consider two projects A and B. Project B (a library) is shown below:

namespace B
{
    public class Application
    {
        public this()
        {
            Struct.Extern();
        }
    }

    public struct Struct : this(int value)
    {
        public static extern Self Extern();
    }
}

Project A (a console application that depends on B) looks like this:

using B;

namespace A
{
    static
    {
        public static void Main()
        {
            // Fails to compile with error LNK2019
            let app = new Application();
        }
    }
}

namespace B
{
    public extension Struct
    {
        public static override void Extern()
        {
        }
    }
}

This code fails to compile with error LNK2019, stating that Struct.Extern is an unresolved external symbol. Modifying Main to call Struct.Extern directly compiles successfully.

public static void Main()
{
    // Success!
    Struct.Extern();
}
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

1 participant