Last active
November 26, 2018 15:11
-
-
Save malte-v/3623a21e1977f562baf6dcf44df2ef08 to your computer and use it in GitHub Desktop.
Crystal shared library demo
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
fun init = crystal_init(argc : Int32, argv : UInt8**) : Void | |
GC.init | |
LibCrystalMain.__crystal_main(argc, argv) | |
end | |
fun log = crystal_log(text: UInt8*): Void | |
puts String.new(text) | |
end |
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
LIBRARY logger | |
EXPORTS | |
crystal_init | |
crystal_log |
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
#ifndef _CRYSTAL_LOGGER_H | |
#define _CRYSTAL_LOGGER_H | |
void crystal_init(int argc, char *argv[]); | |
void crystal_log(char* text); | |
#endif |
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 "logger.h" | |
int main(int argc, char *argv[]) { | |
crystal_init(argc, argv); | |
crystal_log("Hello world!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment