Created
March 27, 2017 18:39
-
-
Save elorest/69926158da97b9fb0e7b69f6a3cb89fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[Link(ldflags: "#{__DIR__}/say.o")] | |
@[Link("m")] | |
lib LibSay | |
struct Person | |
name : UInt8* | |
height : UInt8* | |
age : Int32 | |
end | |
fun hello_ptr(p : LibSay::Person*) : Void | |
fun hello(p : LibSay::Person) : Void | |
end | |
p = LibSay::Person.new(name: "Isaac", age: 33, height: "5'11\"") | |
LibSay.hello_ptr(pointerof(p)) | |
LibSay.hello(p) | |
lib LibMath | |
fun pow(x : Float64, y : Float64) : Float64 | |
end | |
puts LibMath.pow(2,3).to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct Person{ | |
char * name; | |
char * height; | |
int age; | |
}; | |
void hello_ptr(const struct Person * p){ | |
printf("Hello %s! Are you really %d and only %s tall?\n", p->name, p->age, p->height); | |
} | |
void hello(struct Person p){ | |
printf("Hello %s! Are you really %d and only %s tall?\n", p.name, p.age, p.height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment