c3-web icon indicating copy to clipboard operation
c3-web copied to clipboard

C interoperability part seems to have some problems?

Open 707state opened this issue 9 months ago • 1 comments

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?

707state avatar Jan 24 '25 14:01 707state