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

C interoperability part seems to have some problems? #104

Open
707state opened this issue Jan 24, 2025 · 0 comments
Open

C interoperability part seems to have some problems? #104

707state opened this issue Jan 24, 2025 · 0 comments

Comments

@707state
Copy link

OS: Arch linux amd64
C Compiler: gcc-14.2.1

I followed the documentation, compiled foo.c3 to static-lib using c3c static-lib command, and renamed foo.a to libfoo.a.

However, I have no clue on this part:

int foo_square(int) __attribute__ ((weak, alias ("foo.square")));
  1. No symbol 'foo.square' in foo.a
    I used nm to check the symbol
nm -g foo.a

and I could see foo__square in the output, so I changed alias name to foo__square. It didn't work.
The compile command:

gcc test.c -L. -l foo -o main

or

gcc test.c -L. -l foo -Wl,--defsym=foo_square=foo__square

didn't compile. I changed to C code.
2. Use extern or asm instead.
To compile, I changed the C code to this:

int foo_square(int) asm("foo__square");

and it compiled successfully with proper result.

I'm not sure why the export symbols is different, perhaps it's platform depent?

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