Add static lib.

This commit is contained in:
Christoffer Lerno
2024-12-26 23:40:06 +01:00
committed by Christoffer Lerno
parent 08e8c9bf57
commit 291b26f230
5 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
module add;
import std;
struct Foo(Printable)
{
int a;
}
fn usz! Foo.to_format(&self, Formatter* f) @dynamic
{
return f.printf("Foo[%d]", self.a);
}
fn int add(int a, int b) @export("adder")
{
io::printn("In adder");
Foo x = { a };
io::printfn("Print foo: %s", x);
return a + b;
}

View File

@@ -0,0 +1,8 @@
#include <stdio.h>
extern int adder(int a, int b);
int main()
{
printf("%d\n", adder(1, 4));
return 0;
}

View File

@@ -0,0 +1,9 @@
module add;
import std;
extern fn int adder(int a, int b);
fn int main()
{
io::printn(adder(1, 4));
return 0;
}