diff options
| author | 2025-02-15 23:55:18 +0100 | |
|---|---|---|
| committer | 2025-02-16 00:02:44 +0100 | |
| commit | 6848e1c9d7ee412fafb5cb186f2a72ab195d08d8 (patch) | |
| tree | 93f19a2fddb4d2e7a88ade460dbf0b75893caf9e | |
| parent | the loadable extension is tested with the 'test' target (diff) | |
| download | zig-sqlite-6848e1c9d7ee412fafb5cb186f2a72ab195d08d8.tar.gz zig-sqlite-6848e1c9d7ee412fafb5cb186f2a72ab195d08d8.tar.xz zig-sqlite-6848e1c9d7ee412fafb5cb186f2a72ab195d08d8.zip | |
examples(zigcrypto): fix for windows
| -rw-r--r-- | examples/zigcrypto_test.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/zigcrypto_test.zig b/examples/zigcrypto_test.zig index 69a30bc..9c966ac 100644 --- a/examples/zigcrypto_test.zig +++ b/examples/zigcrypto_test.zig | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | const builtin = @import("builtin"); | ||
| 1 | const std = @import("std"); | 2 | const std = @import("std"); |
| 2 | const debug = std.debug; | 3 | const debug = std.debug; |
| 3 | const mem = std.mem; | 4 | const mem = std.mem; |
| @@ -24,8 +25,13 @@ pub fn main() anyerror!void { | |||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | { | 27 | { |
| 28 | const extension_path = if (builtin.os.tag == .windows) | ||
| 29 | "./zig-out/bin/zigcrypto.dll" | ||
| 30 | else | ||
| 31 | "./zig-out/lib/libzigcrypto"; | ||
| 32 | |||
| 27 | var pzErrMsg: [*c]u8 = undefined; | 33 | var pzErrMsg: [*c]u8 = undefined; |
| 28 | const result = sqlite.c.sqlite3_load_extension(db.db, "./zig-out/lib/libzigcrypto", null, &pzErrMsg); | 34 | const result = sqlite.c.sqlite3_load_extension(db.db, extension_path, null, &pzErrMsg); |
| 29 | if (result != sqlite.c.SQLITE_OK) { | 35 | if (result != sqlite.c.SQLITE_OK) { |
| 30 | const err = sqlite.c.sqlite3_errstr(result); | 36 | const err = sqlite.c.sqlite3_errstr(result); |
| 31 | std.debug.panic("unable to load extension, err: {s}, err message: {s}\n", .{ err, std.mem.sliceTo(pzErrMsg, 0) }); | 37 | std.debug.panic("unable to load extension, err: {s}, err message: {s}\n", .{ err, std.mem.sliceTo(pzErrMsg, 0) }); |