Skip to content

Commit 77567f4

Browse files
committed
cgosqlite: use conventional comment style for C preambles
Discussed briefly in #113, a cleanup to follow common style. Updates #113
1 parent 15f073d commit 77567f4

File tree

3 files changed

+59
-53
lines changed

3 files changed

+59
-53
lines changed

cgosqlite/cgosqlite.go

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
11
package cgosqlite
22

3+
/*
34
// This list of compiler options is heavily influenced by:
45
//
56
// https://www.sqlite.org/compile.html#recommended_compile_time_options
67
//
78
// One exception is we do not use SQLITE_OMIT_DECLTYPE, as the design
89
// of the database/sql driver seems to require it.
910
10-
// #cgo CFLAGS: -DSQLITE_THREADSAFE=2
11-
// #cgo CFLAGS: -DSQLITE_DQS=0
12-
// #cgo CFLAGS: -DSQLITE_DEFAULT_MEMSTATUS=0
13-
// #cgo CFLAGS: -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1
14-
// #cgo CFLAGS: -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
15-
// #cgo CFLAGS: -DSQLITE_MAX_EXPR_DEPTH=0
16-
// #cgo CFLAGS: -DSQLITE_OMIT_DEPRECATED
17-
// #cgo CFLAGS: -DSQLITE_OMIT_PROGRESS_CALLBACK
18-
// #cgo CFLAGS: -DSQLITE_OMIT_SHARED_CACHE
19-
// #cgo CFLAGS: -DSQLITE_USE_ALLOCA
20-
// #cgo CFLAGS: -DSQLITE_OMIT_AUTOINIT
21-
// #cgo CFLAGS: -DSQLITE_OMIT_LOAD_EXTENSION
22-
// #cgo CFLAGS: -DSQLITE_ENABLE_FTS5
23-
// #cgo CFLAGS: -DSQLITE_ENABLE_RTREE
24-
// #cgo CFLAGS: -DSQLITE_ENABLE_JSON1
25-
// #cgo CFLAGS: -DSQLITE_ENABLE_SESSION
26-
// #cgo CFLAGS: -DSQLITE_ENABLE_SNAPSHOT
27-
// #cgo CFLAGS: -DSQLITE_ENABLE_PREUPDATE_HOOK
28-
// #cgo CFLAGS: -DSQLITE_ENABLE_COLUMN_METADATA
29-
// #cgo CFLAGS: -DSQLITE_ENABLE_STAT4
30-
// #cgo CFLAGS: -DSQLITE_ENABLE_DBSTAT_VTAB=1
31-
// #cgo CFLAGS: -DSQLITE_TEMP_STORE=1
32-
// #cgo CFLAGS: -DHAVE_USLEEP=1
33-
//
34-
// // Select POSIX 2014 at least for clock_gettime.
35-
// #cgo CFLAGS: -D_XOPEN_SOURCE=600
36-
// #cgo CFLAGS: -D_DARWIN_C_SOURCE=1
37-
//
38-
// // Ignore unknown warning options, to silence spurious complaints from
39-
// // Apple's build of Clang that does not know certain GCC warnings.
40-
// #cgo CFLAGS: -Wno-unknown-warning-option
41-
//
42-
// // Quiet bogus warnings (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115274)
43-
// #cgo CFLAGS: -Wno-stringop-overread
44-
//
45-
// // libm is required by the FTS5 extension, on Linux.
46-
// #cgo linux LDFLAGS: -lm
47-
//
48-
// #include "cgosqlite.h"
11+
#cgo CFLAGS: -DSQLITE_THREADSAFE=2
12+
#cgo CFLAGS: -DSQLITE_DQS=0
13+
#cgo CFLAGS: -DSQLITE_DEFAULT_MEMSTATUS=0
14+
#cgo CFLAGS: -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1
15+
#cgo CFLAGS: -DSQLITE_LIKE_DOESNT_MATCH_BLOBS
16+
#cgo CFLAGS: -DSQLITE_MAX_EXPR_DEPTH=0
17+
#cgo CFLAGS: -DSQLITE_OMIT_DEPRECATED
18+
#cgo CFLAGS: -DSQLITE_OMIT_PROGRESS_CALLBACK
19+
#cgo CFLAGS: -DSQLITE_OMIT_SHARED_CACHE
20+
#cgo CFLAGS: -DSQLITE_USE_ALLOCA
21+
#cgo CFLAGS: -DSQLITE_OMIT_AUTOINIT
22+
#cgo CFLAGS: -DSQLITE_OMIT_LOAD_EXTENSION
23+
#cgo CFLAGS: -DSQLITE_ENABLE_FTS5
24+
#cgo CFLAGS: -DSQLITE_ENABLE_RTREE
25+
#cgo CFLAGS: -DSQLITE_ENABLE_JSON1
26+
#cgo CFLAGS: -DSQLITE_ENABLE_SESSION
27+
#cgo CFLAGS: -DSQLITE_ENABLE_SNAPSHOT
28+
#cgo CFLAGS: -DSQLITE_ENABLE_PREUPDATE_HOOK
29+
#cgo CFLAGS: -DSQLITE_ENABLE_COLUMN_METADATA
30+
#cgo CFLAGS: -DSQLITE_ENABLE_STAT4
31+
#cgo CFLAGS: -DSQLITE_ENABLE_DBSTAT_VTAB=1
32+
#cgo CFLAGS: -DSQLITE_TEMP_STORE=1
33+
#cgo CFLAGS: -DHAVE_USLEEP=1
34+
35+
// Select POSIX 2014 at least for clock_gettime.
36+
#cgo CFLAGS: -D_XOPEN_SOURCE=600
37+
#cgo CFLAGS: -D_DARWIN_C_SOURCE=1
38+
39+
// Ignore unknown warning options, to silence spurious complaints from
40+
// Apple's build of Clang that does not know certain GCC warnings.
41+
#cgo CFLAGS: -Wno-unknown-warning-option
42+
43+
// Quiet bogus warnings (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115274)
44+
#cgo CFLAGS: -Wno-stringop-overread
45+
46+
// libm is required by the FTS5 extension, on Linux.
47+
#cgo linux LDFLAGS: -lm
48+
49+
#include "cgosqlite.h"
50+
*/
4951
import "C"
5052
import (
5153
"sync"

cgosqlite/logcallback.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package cgosqlite
22

3-
// #include <sqlite3.h>
4-
//
5-
// void logCallbackGo(void* userData, int errCode, char* msgC);
6-
//
7-
// static void log_callback_into_go(void *userData, int errCode, const char *msg) {
8-
// logCallbackGo(userData, errCode, (char*)msg);
9-
// }
10-
//
11-
// static int ts_sqlite3_config_log(void) {
12-
// // TODO(raggi): if the library gains new uses of sqlite3_config they need to
13-
// // share a mutex.
14-
// return sqlite3_config(SQLITE_CONFIG_LOG, log_callback_into_go, NULL);
15-
// }
3+
/*
4+
#include <sqlite3.h>
5+
6+
void logCallbackGo(void* userData, int errCode, char* msgC);
7+
8+
static void log_callback_into_go(void *userData, int errCode, const char *msg) {
9+
logCallbackGo(userData, errCode, (char*)msg);
10+
}
11+
12+
static int ts_sqlite3_config_log(void) {
13+
// TODO(raggi): if the library gains new uses of sqlite3_config they need to
14+
// share a mutex.
15+
return sqlite3_config(SQLITE_CONFIG_LOG, log_callback_into_go, NULL);
16+
}
17+
*/
1618
import "C"
1719
import (
1820
"sync"

cgosqlite/walcallback.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cgosqlite
22

3-
// #include <sqlite3.h>
3+
/*
4+
#include <sqlite3.h>
5+
*/
46
import "C"
57
import (
68
"sync"

0 commit comments

Comments
 (0)