mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add static lib.
This commit is contained in:
committed by
Christoffer Lerno
parent
08e8c9bf57
commit
291b26f230
19
resources/examples/staticlib-test/add.c3
Normal file
19
resources/examples/staticlib-test/add.c3
Normal 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;
|
||||
}
|
||||
8
resources/examples/staticlib-test/test.c
Normal file
8
resources/examples/staticlib-test/test.c
Normal 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;
|
||||
}
|
||||
9
resources/examples/staticlib-test/test.c3
Normal file
9
resources/examples/staticlib-test/test.c3
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user