-
-
Save awr1/93470331d4ec0626930d2e6b1433b48c 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
# compile with | |
# nim c --app:dll -o:app.dll app.nim | |
# nim c --app:exe -o:app.exe app.nim | |
# then run app.exe | |
when compileOption("app", "exe"): | |
type App = ptr object | |
{.pragma: appImport, importc, nimcall, dynlib: "app".} | |
proc newApp() :App {.appImport.} | |
proc run(app :App) {.appImport.} | |
var app = newApp() | |
app.run | |
elif compileOption("app", "dll"): | |
type App = ptr object | |
{.pragma: appExport, exportc, nimcall, dynlib.} | |
proc newApp() :App {.appExport.} = nil | |
proc run(app :App) {.appExport.} = echo("run() from DLL") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment