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

About macro #1690

Open
LukyGuyLucky opened this issue Dec 17, 2024 · 0 comments
Open

About macro #1690

LukyGuyLucky opened this issue Dec 17, 2024 · 0 comments

Comments

@LukyGuyLucky
Copy link

LukyGuyLucky commented Dec 17, 2024

When do an exercise according to test/test_suite/macros/macro_import_res_private.c3t,adding printf to print some information,it failed to compile with message:

E:\Learning\c3pack\ex\test\test_suite\macros>c3c compile-run macro_import_res_private.c3
lld-link: error: undefined symbol: printf.2
>>> referenced by E:\Learning\c3pack\ex\test\test_suite\macros\macro_import_res_private.c3:31
>>>               baz.obj:(baz.main)
Failed to create an executable: (null)

The message is so compact that I have no clue to printf.2.When I change macro bar1() to macro @bar1() at both place,it doesn't help;when I change printf to io::printfn,it compiles;when I change macro bar1() to fn void bar1(),it compiles and works.

So may I ask what the issue is please?

// #target: macos-x64
module foo;
import std::io;
extern fn int printf(char*,...);

fn void foo1() @private
{
    printf("Inside module foo.foo1():\n");
}

module bar;
import foo @public;
extern fn int printf(char*,...);
macro bar1()
{
    printf("Inside module bar.bar1():\n");
    foo::foo1();
}

module baz;
import bar;
extern fn int printf(char*,...);
macro test()
{
    printf("Inside module baz.test():\n");
    bar::bar1();
}
fn void main()
{
    printf("Inside module baz.main():\n");
    test();
}

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