Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/syntax_and_semantics/c_bindings/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ Attributes are used to pass flags to the linker to find external libraries:
* `@[Link(framework: "Cocoa")]` will pass `-framework Cocoa` to the linker (only useful in macOS).

Attributes can be omitted if the library is implicitly linked, as in the case of libc.

## Reflection

Lib functions are visible in the macro language anywhere in the program using the method [`TypeNode#methods`](https://crystal-lang.org/api/Crystal/Macros/TypeNode.html#methods%3AArrayLiteral%28Def%29-instance-method):

```crystal
lib LibFoo
fun foo
end

{{ LibFoo.methods }} # => [fun foo]
Comment thread
straight-shoota marked this conversation as resolved.
```