Skip to content

Commit b252268

Browse files
committed
fix when building for windows using clang
1 parent d196488 commit b252268

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ https://godoc.org/crawshaw.io/sqlite
5353

5454
## Platform specific considerations
5555

56-
By default it requires some pthreads DLL on Windows. To avoid it, supply `CGOLDFLAGS="-static"` when building your application.
56+
By default it requires some pthreads DLL on Windows. To avoid it, supply `CGO_LDFLAGS="-static"` when building your application.

auth.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package sqlite
22

33
// #include <stdint.h>
44
// #include <sqlite3.h>
5-
// extern int go_sqlite_auth_tramp(uintptr_t, int, char*, char*, char*, char*);
6-
// static int c_auth_tramp(void *userData, int action, const char* arg1, const char* arg2, const char* db, const char* trigger) {
7-
// return go_sqlite_auth_tramp((uintptr_t)userData, action, (char*)arg1, (char*)arg2, (char*)db, (char*)trigger);
8-
// }
5+
//
6+
// extern int c_auth_tramp(void*, int, const char*, const char*, const char*, const char*);
97
// static int sqlite3_go_set_authorizer(sqlite3* conn, uintptr_t id) {
108
// return sqlite3_set_authorizer(conn, c_auth_tramp, (void*)id);
119
// }

sqlite.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ package sqlite
5252
// return sqlite3_bind_blob(stmt, col, p, n, SQLITE_TRANSIENT);
5353
// }
5454
//
55-
// extern void log_fn(void* pArg, int code, char* msg);
55+
// extern void c_log_fn(void*, int, char*);
5656
// static void enable_logging() {
57-
// sqlite3_config(SQLITE_CONFIG_LOG, log_fn, NULL);
57+
// sqlite3_config(SQLITE_CONFIG_LOG, c_log_fn, NULL);
5858
// }
5959
//
6060
// static int db_config_onoff(sqlite3* db, int op, int onoff) {
@@ -170,7 +170,6 @@ func openConn(path string, flags ...OpenFlags) (*Conn, error) {
170170
}
171171
}
172172

173-
174173
return conn, nil
175174
}
176175

@@ -1224,8 +1223,8 @@ func sqliteInitFn() {
12241223
}
12251224
}
12261225

1227-
//export log_fn
1228-
func log_fn(_ unsafe.Pointer, code C.int, msg *C.char) {
1226+
//export go_log_fn
1227+
func go_log_fn(_ unsafe.Pointer, code C.int, msg *C.char) {
12291228
var msgBytes []byte
12301229
if msg != nil {
12311230
str := C.GoString(msg) // TODO: do not copy msg.

wrappers.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ void c_destroy_tramp(void* ptr) {
4747
return go_destroy_tramp((uintptr_t)ptr);
4848
}
4949

50+
extern int go_sqlite_auth_tramp(uintptr_t, int, char*, char*, char*, char*);
51+
int c_auth_tramp(void *userData, int action, const char* arg1, const char* arg2, const char* db, const char* trigger) {
52+
return go_sqlite_auth_tramp((uintptr_t)userData, action, (char*)arg1, (char*)arg2, (char*)db, (char*)trigger);
53+
}
54+
55+
extern void go_log_fn(void*, int, char*);
56+
void c_log_fn(void* pArg, int code, char* msg) {
57+
return go_log_fn(pArg, code, msg);
58+
}

0 commit comments

Comments
 (0)