Skip to content

C interoperability part seems to have some problems? #104

@707state

Description

@707state

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?

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions