SQLite Forum

Build Error: sqlite3.c(206932): error C2061: syntax error: identifier 'sqlite3_session'
Login

Build Error: sqlite3.c(206932): error C2061: syntax error: identifier 'sqlite3_session'

(1) By Keith Medcalf (kmedcalf) on 2021-07-07 19:21:15 [link] [source]

I am suddenly getting the error:

sqlite3.c(206932): error C2061: syntax error: identifier 'sqlite3_session'

when compiling with SQLITE_ENABLE_PREUPDATE_HOOK and SQLITE_ENABLE_SESSION though I fail to see what is causing the problem.

This from the fossil repo up-to-date as of 8bdd5fbf12

Not defining SQLITE_ENABLE_SESSION makes the error go away (along with the session extension).

Compiler is MSVC (Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30038.1 for x64)

gcc produces the error sqlite3.c:206932:3: error: unknown type name 'sqlite3_session'

(2) By Keith Medcalf (kmedcalf) on 2021-07-07 19:36:59 in reply to 1 [link] [source]

Bisect indicates e306952690 is the problem checkin.

(3) By Larry Brasfield (larrybr) on 2021-07-07 20:17:47 in reply to 2 [link] [source]

Thanks, Keith, for doing the bisect.

I have done default shell builds on trunk tip (version 7072404ad0267b8e) and version e306952690, for Linux (using gcc), and MSVC builds using "nmake -f Makefile.msc SESSION=1 sqlite3.exe" for the same versions, all of which cause SQLITE_ENABLE_PREUPDATE_HOOK and SQLITE_ENABLE_SESSION to be defined. These 4 builds all succeed.

Before starting any of those builds, I did a "make clean" (or "nmake -f Makefile.msc clean"), so I suspect we are doing a slightly different build. Could you please try the same? At present, I am unable to repro the problem you report.

If not for you seeing the problem with both gcc and MSVC (both on Windows, I suppose), I would be tempted to setup for gcc builds on Windows. But since I do not see the MSVC compile error, I lean toward something odd left laying around on your system being responsible. At least until you have the problem after a clean.

(4) By Keith Medcalf (kmedcalf) on 2021-07-07 23:02:40 in reply to 3 [link] [source]

You are quite correct. Some other option is causing the error. I do not know which one yet. Figuring it out will be a long process, however it is broken.

(5) By Larry Brasfield (larrybr) on 2021-07-07 23:07:08 in reply to 4 [link] [source]

I will be happy to investigate if you'll say what build options you are using. (Not turning down the volunteered hunt.) I suspect, as I think you do, that there is an improvement opportunity here. Build option combinations, even if somewhat non-useful, should produce either a build or a meaningful complaint. IMHO.

(6) By Keith Medcalf (kmedcalf) on 2021-07-08 00:02:51 in reply to 3 [source]

Ok. Figured it out. It is because "config.h" is now being loaded after a bunch of other headers. If I add the block to include config.h to the top of sqlite3.c then it works.

Note -- this is because I put all the configuration options in config.h which also includes the all the sqlite configuration defines. This works for both MSVC and GCC ...

Previously, this was the first loaded header. Now it is not. The following fixes it by making sure it is the first header loaded:

Index: tool/mksqlite3c.tcl
==================================================================
--- tool/mksqlite3c.tcl
+++ tool/mksqlite3c.tcl
@@ -78,22 +78,25 @@
 ** if you want a wrapper to interface SQLite with your choice of programming
 ** language. The code for the "sqlite3" command-line shell is also in a
 ** separate file. This file contains only code for the core SQLite library.
 */
 #define SQLITE_CORE 1
-#define SQLITE_AMALGAMATION 1}]
+#define SQLITE_AMALGAMATION 1
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
+#include "config.h"
+#define SQLITECONFIG_H 1
+#endif}]
 if {$addstatic} {
   puts $out \
 {#ifndef SQLITE_PRIVATE
 # define SQLITE_PRIVATE static
 #endif}
 }

(7) By Larry Brasfield (larrybr) on 2021-07-08 01:14:08 in reply to 6 [link] [source]

Before getting to any detailed discussion on this, I want to make a few facts clear:

  • I am not adverse to moving the config.h include position on implacable principle.

  • I am not adverse to carefully considering your suggested fix.

  • A change will require several hours of testing to land on trunk.

  • I am not yet convinced that moving where config.h is included is the best fix.

  • Any change will have to be done very carefully and pass muster before other project developers. A reasoned defense may be necessary.

  • I appreciate your effort to investigate this and diagnosis.

The reason I am unconvinced is that, generally, we1 like headers to not interfere with each other, to be include-order independent, and if one is dependent on another, that they perform such includes as they need for themselves. I see this as particularly important for commonly used library code.

If bringing the generated config.h and other non-system headers to that likable state will cure your problem, (regardless of what precisely led to it), that is going to be my preferred fix. (I am open to reasons to not so prefer.)

If the conflicting headers cannot be made include-order independent, I want to understand why before reverting to the "pragmatic"2 remedy of reordering includes. It would help me better see the larger context to understand what you did to a generated config.h that made its include ranking important. I will want to understand the breakage you induced in detail to help pinpoint where the header conflict is occurring. (IOW, I want repro.)

I am open to the proposition, (and hold it personally), that a config.h file is a good place to put local feature configuration definitions. So I am disinclined to say anything like, "Just don't modify config.h". Hence, I am interested in solving your problem because I doubt it is one unique to you. (You may be unique in bringing the problem here, but that is fine!)

So, I am asking for a little help, (repro mainly), so that I can know what is the best fix and can defend it if called upon to do so.3


1. By "we", I mean software developers generally.

2. Dogmatism and adherence to good practice must sometimes be distinguished.

3. In fact, I do not make changes without believing I can defend them.

(8) By David Jones (vman59) on 2021-07-08 03:02:18 in reply to 7 [link] [source]

If you're using config.h as a way to make an otherwise lengthy command line for the compiler invocation shorter, you'd want the include to happen first thing.

(10) By Larry Brasfield (larrybr) on 2021-07-08 12:41:05 in reply to 8 [link] [source]

I agree with that want. My main hesitation arises from the fact that config.h is generated. Please consider my reply #9 as an alternative to fiddling with include reordering.

(9.1) By Larry Brasfield (larrybr) on 2021-07-08 13:09:39 edited from 9.0 in reply to 6 [link] [source]

(Without abandoning my reply #7:) (Edited to add stringification of PP symbol to name include file.)

What would you (or others) think of having the shell and library revised with something like #ifdef SQLITE_CUSTOM_INC # define INC_STRINGIFY_(f) #f # define INC_STRINGIFY(f) INC_STRINGIFY_(f) # include INC_STRINGIFY(SQLITE_CUSTOM_INC) #endif appearing early enough in the translation(s) that it can be a substitute for a bunch of -D... compile options?

(11) By Keith Medcalf (kmedcalf) on 2021-07-08 17:51:06 in reply to 9.1 [link] [source]

Sounds good. As an aside, I used the "config.h" for this because (a) you do not run autoconfig on Windows and (b) it is a convenient place to put all the options which would otherwise make the command line very long (plus you can annotate it since it is a source file that can contain comments).

For example, my current "config.h" that I include looks like this:

#ifndef _CONFIG_H
#define _CONFIG_H


// Values of WINVER and _WIN32_WINNT for various minimum levels of Win32 Compatability
//
// WIN10    0x0A00      WIN6     0x0600      W2K      0x0500     NT4      0x0400
//                      VISTA    0x0600      WXP      0x0501     W95      0x0400
//                      W2K8     0x0600      W2K3     0x0502     NT4E     0x0401
//                      WIN7     0x0601                          W98      0x0410
//                      WIN8     0x0602                          WME      0x0490
//                      WIN81    0x0603

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0A00
#endif
#ifndef WINVER
#define WINVER _WIN32_WINNT
#endif


// *** SQLITE GENERAL CONFIGURATION OPTIONS ***

// #define SQLITE_DEFAULT_AUTOMATIC_INDEX      1               // default: 1
// #define SQLITE_DEFAULT_AUTOVACUUM           0               // default: 0

// Set Default Page Cache Size and Temp Cache Size based on Memory Model

#if defined(_WIN64)
#define SQLITE_DEFAULT_CACHE_SIZE        -1048576           // 1024 MB default: 2 MB
#define SQLITE_DEFAULT_TEMP_CACHE_SIZE    -262144           //  256 MB default:  500 pages
#else
#define SQLITE_DEFAULT_CACHE_SIZE         -262144           //  256 MB default:  2 MB pages
#define SQLITE_DEFAULT_TEMP_CACHE_SIZE     -65536           //   64 MB default:   500 pages
#endif

#define SQLITE_DEFAULT_DEFENSIVE            1               // default:  undefined or off
// #define SQLITE_DEFAULT_FILE_FORMAT          4               // default: 4
// #define SQLITE_DEFAULT_FILE_PERMISSIONS     0644            // default: 0644
#define SQLITE_DEFAULT_FOREIGN_KEYS         1               // default: 0
// #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT   4194304         // default: -1
// #define SQLITE_DEFAULT_LOCKING_MODE         0               // default: 0
#define SQLITE_DEFAULT_MEMSTATUS            1               // default: 1
// #define SQLITE_DEFAULT_MMAP_SIZE            0               // default: 0
#define SQLITE_DEFAULT_PAGE_SIZE            4096            // default: 4096 max: 65536
// #define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755            // default: 0755
#define SQLITE_DEFAULT_RECURSIVE_TRIGGERS   1               // default: 0
// #define SQLITE_DEFAULT_SHARED_CACHE         0               // default: 0
// #define SQLITE_DEFAULT_SYNCHRONOUS          2               // default: 2
#define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT   256             // default: 1000 pages
// #define SQLITE_DEFAULT_WAL_SYNCHRONOUS      2               // default: same as default synchronous
#define SQLITE_DEFAULT_WORKER_THREADS       8               // default: 0
// #define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1               // default: undefined
// #define SQLITE_SORTER_PMASZ                 64              // default: 250
// #define SQLITE_EXTRA_DURABLE                1               // Extra DirSync's default not defined


// *** SQLITE FEATURE CONFIGURATION OPTIONS ***

#define RBU_ENABLE_DELTA_CKSUM 1                            // Enable RBU Update Checksum (disabled by default)
// #define SQLITE_64BIT_STATS 1
#define SQLITE_ALLOW_URI_AUTHORITY 1                        // Allow Authority (Host) in URI
#define SQLITE_ALLOW_COVERING_INDEX_SCAN 1                  // Allow Covering Index Scans
// #define SQLITE_CASE_SENSITIVE_LIKE 1                        // Like is case sensitive (default is not case sensitive)
#define SQLITE_COUNTOFVIEW_OPTIMIZATION 1                   // Additional Optimization for count()
// #define SQLITE_DISABLE_DIRSYNC 1                            // Do not sync directories
// #define SQLITE_DISABLE_FTS3_UNICODE 1                       // Disable Unicode in FTS3
// #define SQLITE_DISABLE_LFS 1
// #define SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS 1           // Disable Overflow Page Statistics
#define SQLITE_DQS 0                                        // Double Quoted Strings (0=None/1=DML/2=DDL/3=Both)
#define SQLITE_INTROSPECTION_PRAGMAS 1                      // Add Instropsection Pragma
#define SQLITE_ENABLE_8_3_NAMES 1                           // Enable 8.3 Names
#define SQLITE_ENABLE_API_ARMOR 1                           // Enable API Armour
// #define SQLITE_ENABLE_ATOMIC_WRITE 1                        // Enable Atomic Writes
#define SQLITE_ENABLE_BYTECODE_VTAB 1                       // Enable Bytecode VTAB
#define SQLITE_ENABLE_COLUMN_METADATA 1                     // Add Column Metadata Functions
#define SQLITE_ENABLE_COLUMN_USED_MASK 1                    // Enable Column Used Hints
#define SQLITE_ENABLE_COSTMULT 1                            // Use Cost Multiplication Factors
#define SQLITE_ENABLE_CURSOR_HINTS 1                        // Output Cursor Hints to B-Tree Layer
#define SQLITE_ENABLE_DBPAGE_VTAB 1                         // Include DBPAGE Virtual Table
#define SQLITE_ENABLE_DBSTAT_VTAB 1                         // Include DBSTAT Virtual Table
#define SQLITE_ENABLE_DESERIALIZE 1                         // Include Serialize/Deserialize API
#define SQLITE_ENABLE_EXPLAIN_COMMENTS 1                    // Add Comments to Explain
#define SQLITE_ENABLE_FTS3 1                                // Include FTS3 Extension
#define SQLITE_ENABLE_FTS3_PARENTHESIS 1                    // FTS3 Options
#define SQLITE_ENABLE_FTS4 1                                // Include FTS4 Extension
#define SQLITE_ENABLE_FTS5 1                                // Include FTS5 Extension
#define SQLITE_ENABLE_GEOPOLY 1                             // Include the GEOPOLY Extension
// #define SQLITE_ENABLE_HIDDEN_COLUMNS 1                      // Allow Hidden Columns
// #define SQLITE_ENABLE_ICU 1                                 // Set in BUILD Command additional Libs required
#define SQLITE_ENABLE_JSON1 1                               // Enable JSON1 Extension
#define SQLITE_ENABLE_LOAD_EXTENSION 1                      // Enable the Load Extension Interface
#define SQLITE_ENABLE_LOCKING_STYLE 1                       // Locking Style (1 == Normal)
#define SQLITE_ENABLE_LSM1 1                                // Enable LSM1
#define SQLITE_ENABLE_MATH_FUNCTIONS 1                      // Enable Math Functions
#define SQLITE_HAVE_C99_MATH_FUNCS (1)                      // Have C99 MATH FUNCS
#define SQLITE_ENABLE_MEMORY_MANAGEMENT 1                   // Enable Memory Management (sqlite3_release_memory)
#define SQLITE_ENABLE_MEMSTATVTAB 1                         // Enable the memstat vtab
// #define SQLITE_ENABLE_MEMSYS3 1                             // Include MEMSYS3
// #define SQLITE_ENABLE_MEMSYS5 1                             // Include MEMSYS5
#define SQLITE_ENABLE_MODULE_COMMENTS 1                     // Add Module Comments to Explain
// #define SQLITE_ENABLE_MULTITHREADED_CHECKS 1                // Enable Multithreaded Checks when using MUTLITHREADING config
#define SQLITE_ENABLE_NORMALIZE 1                           // Enable the sqlite3_normalized_sql interface
#define SQLITE_ENABLE_PREUPDATE_HOOK 1                      // Enable the pre-commit hooks
// #define SQLITE_ENABLE_QPSG                                  // Enable Query Planner Stability Guarantee
#define SQLITE_ENABLE_RBU 1                                 // Enable Resumable Bulk Update
#define SQLITE_ENABLE_RTREE 1                               // Include the RTREE Extension
// #define SQLITE_RTREE_INT_ONLY 1                             // Make RTREE Integer Only (rather than float32)
#define SQLITE_ENABLE_SESSION 1                             // Enable the SESSION feature
// #define SQLITE_ENABLE_SETLK_TIMEOUT 1                       // Use File Control to manage lock acquisition
#define SQLITE_ENABLE_SNAPSHOT 1                            // Enable the SNAPSHOT feature
// #define SQLITE_ENABLE_SORTER_REFERENCES 1                   // Enable Sorter References
#define SQLITE_ENABLE_STAT_VTAB 1                           // Enable dbstat_register called from shell
#define SQLITE_ENABLE_STAT1 1                               // Enable Statistics 1
#define SQLITE_ENABLE_STAT2 1                               // Enable Statistics 2
#define SQLITE_ENABLE_STAT3 1                               // Enable Statistics 3
#define SQLITE_ENABLE_STAT4 1                               // Enable Statistics 4
#define SQLITE_ENABLE_STMTVTAB 1                            // Enable Stmt VTAB Extension
#define SQLITE_ENABLE_STMT_SCANSTATUS 1                     // Enable Statement ScanStatus
#define SQLITE_ENABLE_UNIONVTAB 1                           // Enable unionvtab
#define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION 1                // Allow Explain to work for Unknown Functions
// #define SQLITE_ENABLE_UNLOCK_NOTIFY 1                       // See Documentation before enabling
#define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1                 // Requires Special Amalgamation / Parser Support
// #define SQLITE_ENABLE_VFSSTAT 1                             // Enable vfsstat extension
#define SQLITE_EXPLAIN_ESTIMATED_ROWS 1                     // Add Estimated Rows to Explain
// #define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1               // default: 0 (undefined)
// #define SQLITE_MMAP_READWRITE 1                             // mmaps are writeable as well as readable
// #define SQLITE_SECURE_DELETE 1                              // Enable Overwriting of deleted records
#define SQLITE_SOUNDEX 1                                    // Include the soundex builtin
#define SQLITE_STAT4_SAMPLES 64                             // default: 24 samples
#define SQLITE_THREADSAFE 1                                 // 0 = Single Threaded, 1 = Serialized, 2 = Multithreaded
#define SQLITE_TEMP_STORE 1                                 // 0 = Files Always, 1 = Files, 2 = Memory, 3 = Memory Always
#define SQLITE_TRUSTED_SCHEMA 0                             // Schema is untrusted -- default trusted
#define SQLITE_USE_URI 1                                    // Enable URI Filenames


//  *** SQLITE MAXIMUMS AND LIMITS CONFIGURATION ***

// #define SQLITE_FTS3_MAX_EXPR_DEPTH          15              // default: 12
#define SQLITE_MAX_ATTACHED                 15              // default: 10          max: 62
// #define SQLITE_MAX_COLUMN                   2000            // default: 2000        max: 32767
// #define SQLITE_MAX_COMPOUND_SELECT          500             // default: 500
// #define SQLITE_MAX_EXPR_DEPTH               1000            // default: 1000
// #define SQLITE_MAX_FUNCTION_ARG             100             // default: 100         max: 127
// #define SQLITE_MAX_LENGTH                   0x3fffffff      // default: 1000000000  max: 2147483647 (2^31-1)
// #define SQLITE_MAX_LIKE_PATTERN_LENGTH      16384           // default: 50000
// #define SQLITE_MAX_MEMORY                   0               // default: 0
// #if defined(_WIN64)
// #define SQLITE_MAX_MEMORY                   4294967296      // 4 GB on x64
// #else
// #define SQLITE_MAX_MEMORY                   1073741824      // 1 GB on x32
// #endif
// #define SQLITE_MAX_MMAP_SIZE                0x7fff0000      // default: 0x7fff0000
// #define SQLITE_MAX_PAGE_COUNT               1073741823      // default: 1073741823  max: 2147483646 (2^31-2)
// #define SQLITE_MAX_SQL_LENGTH               131072          // default: 1000000     max: 2^30
// #define SQLITE_MAX_TRIGGER_DEPTH            1000            // default: 1000
// #define SQLITE_MAX_VARIABLE_NUMBER          32766           // default: 32766
// #define SQLITE_MAX_SCHEMA_RETRY             50              // default: 50
#define SQLITE_MAX_WORKER_THREADS           16              // default: 8
// #define YYSTACKDEPTH                        100             // default: 100


//  *** SQLITE OPERATING SYSTEM AND INTERNALS CONFIGURATION ***

//  #define SQLITE_OS_OTHER 0
#define SQLITE_OS_WIN 1
#define SQLITE_OS_WINNT 1
// #define SQLITE_OS_WINCE 1
// #define SQLITE_OS_WINRT 1
// #define SQLITE_WIN32_MALLOC 1                               // Use Win32 Heap Allocator
// #define SQLITE_WIN32_HEAP_CREATE 1                          // Use Separate Win32 Heap
// #define SQLITE_WIN32_MALLOC_VALIDATE 1                      // Validate Win32 Heap during SQLITE_DEBUG assert
// #if defined(_WIN64)
// #define SQLITE_WIN32_HEAP_INIT_SIZE 1073741824              // Initial Win32 Heap Size = 1 GB
// #else
// #define SQLITE_WIN32_HEAP_INIT_SIZE 268435456               // Initial Win32 Heap Size = 256 MB
// #endif
// #define SQLITE_WIN32_HEAP_MAX_SIZE 0                        // Max Win32 Heap Size (No Limit)
// #define SQLITE_WIN32_HEAP_FLAGS 0
// #define SQLITE_DIRECT_OVERFLOW_READ 1                       // Do Not PageCache Overflow Pages
// #define SQLITE_DEFAULT_LOOKASIDE 1200,100                   // Default LookAside Allocation
// #define SQLITE_SYSTEM_MALLOC 1                              // Use Default System Heap (default if no other specified)
// #define SQLITE_MALLOC_SOFT_LIMIT 1024
// #define SQLITE_POWERSAFE_OVERWRITE 0
// #define SQLITE_4_BYTE_ALIGNED_MALLOC 1
// #define SQLITE_USE_ALLOCA 1                                 // Use AllocA to Allocate Parse object os Stack


// *** SQLITE OMIT FEATURES ***

// #define SQLITE_OMIT_ALTERTABLE
// #define SQLITE_OMIT_ANALYZE
// #define SQLITE_OMIT_ATTACH
// #define SQLITE_OMIT_AUTHORIZATION
// #define SQLITE_OMIT_AUTOINCREMENT
// #define SQLITE_OMIT_AUTOINIT
// #define SQLITE_OMIT_AUTOMATIC_INDEX
// #define SQLITE_OMIT_AUTORESET
// #define SQLITE_OMIT_AUTOVACUUM
// #define SQLITE_OMIT_BETWEEN_OPTIMIZATION
// #define SQLITE_OMIT_BLOB_LITERAL
// #define SQLITE_OMIT_BTREECOUNT
// #define SQLITE_OMIT_BUILTIN_TEST
// #define SQLITE_OMIT_CAST
// #define SQLITE_OMIT_CHECK
// #define SQLITE_OMIT_COMPILEOPTION_DIAGS
// #define SQLITE_OMIT_COMPLETE
// #define SQLITE_OMIT_COMPOUND_SELECT
// #define SQLITE_OMIT_DATETIME_FUNCS
// #define SQLITE_OMIT_DECLTYPE
// #define SQLITE_OMIT_DEPRECATED
// #define SQLITE_OMIT_DISKIO
// #define SQLITE_OMIT_EXPLAIN
// #define SQLITE_OMIT_FLAG_PRAGMAS
// #define SQLITE_OMIT_FLOATING_POINT
// #define SQLITE_OMIT_FOREIGN_KEY
// #define SQLITE_OMIT_GET_TABLE
// #define SQLITE_OMIT_INCRBLOB
// #define SQLITE_OMIT_INTEGRITY_CHECK
// #define SQLITE_OMIT_LIKE_OPTIMIZATION
// #define SQLITE_OMIT_LOAD_EXTENSION
// #define SQLITE_OMIT_LOCALTIME
// #define SQLITE_OMIT_LOOKASIDE
// #define SQLITE_OMIT_MEMORYDB
// #define SQLITE_OMIT_MERGE_SORT
// #define SQLITE_OMIT_OR_OPTIMIZATION
// #define SQLITE_OMIT_PAGER_PRAGMAS
// #define SQLITE_OMIT_PRAGMA
// #define SQLITE_OMIT_PROGRESS_CALLBACK
// #define SQLITE_OMIT_QUICKBALANCE
// #define SQLITE_OMIT_REINDEX
// #define SQLITE_OMIT_SCHEMA_PRAGMAS
// #define SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
// #define SQLITE_OMIT_SHARED_CACHE
// #define SQLITE_OMIT_SHUTDOWN_DIRECTORIES
// #define SQLITE_OMIT_SUBQUERY
// #define SQLITE_OMIT_TCL_VARIABLE
// #define SQLITE_OMIT_TEMPDB
// #define SQLITE_OMIT_TRACE
// #define SQLITE_OMIT_TRIGGER
// #define SQLITE_OMIT_TRUNCATE_OPTIMIZATION
// #define SQLITE_OMIT_UTF16
// #define SQLITE_OMIT_VACUUM
// #define SQLITE_OMIT_VIEW
// #define SQLITE_OMIT_VIRTUALTABLE
// #define SQLITE_OMIT_WAL
// #define SQLITE_OMIT_WSD 1
// #define SQLITE_OMIT_XFER_OPT


// *** SQLITE DEBUGGING FEATURES ***

// #define SQLITE_DEBUG 1
// #define SQLITE_ENABLE_EXPENSIVE_ASSERT 1
// #define SQLITE_ENABLE_OVERSIZE_CELL_CHECK 1
// #define SQLITE_ENABLE_SELECTTRACE 1                         // Enable Select Trace (.selecttrace 0x100) needs SQLITE_DEBUG
// #define SQLITE_ENABLE_SQLLOG 1                              // Enable SQLITE_CONFIG_SQLLOG (see documentation)
// #define SQLITE_ENABLE_STMT_SCANSTATUS 1                     // Enable Collection of Statement Scan Status
// #define SQLITE_ENABLE_WHERETRACE 1
// #define SQLITE_IOTRACE 1
// #define SQLITE_MEMDEBUG 1
// #define SQLITE_REVERSE_UNORDERED_SELECTS 1
// #define SQLITE_USE_FCNTL_TRACE 1                            // Enable extra vfslog fcntrl trace
// #define SQLITE_YYTRACKMAXSTACKDEPTH 1


// *** Custom Additions/Changes/Features ***

#define SQLITE_NOW_STABILITY_STMT 1                         // Make 'now' stable within a statement, not only for a step
#define WHERE_PATH_SIMPLE 50                                // Paths to remember for  2-way joins
#define WHERE_PATH_COMPLEX 100                              // Paths to remember for >2-way joins
#define SQLITE_USE_QUADMATH 1                               // Use 128-bit Float Intermediates if available
#define SQLITE_USE_PRECISE_TIME 1                           // Use GetSystemTimePreciseAsFileTime
#define SQLITE_USE_DATETIME_NEW 1                           // Use New Datetime Functions

// For cache modes only use 1 of RANDOM / SEQUENTIAL / WRITETHROUGH / NOBUFFER
// For WINCE always use RANDOM, default if "Microsoft Magical Mode" if none selected

#define SQLITE_WIN32_FILE_RANDOM 1                          // Force Windows RANDOM access cache behaviour
// #define SQLITE_WIN32_FILE_SEQUENTIAL 1                      // Force Windows SEQUENTIAL access cache behaviour
// #define SQLITE_WIN32_FILE_WRITETHROUGH 1                    // Turn off Delayed Writes
// #define SQLITE_WIN32_FILE_NOBUFFER 1                        // Disable use of Filesystem Cache


// Performance Optimizations

// #define SQLITE_THREADSAFE                   0                   // Remove Thread Safety Mutexes
// #define SQLITE_DEFAULT_MEMSTATUS            0                   // Remove Memory Status from SQLITE3_MALLOC
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS      1                   // Reduce Synchronous to NORMAL in WAL mode
// #define SQLITE_DIRECT_OVERFLOW_READ         1                   // Do not cache overflow pages in SQLite pagecache
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1                   // Disable LIKE matching for BLOBS
// #define SQLITE_MAX_EXPR_DEPTH               0                   // Disable Parser Depth Checking
// #define SQLITE_OMIT_DECLTYPE                1                   // Omit Declaration Type from Cursors
// #define SQLITE_OMIT_DEPRECATED              1                   // Omit Deprecated Code
// #define SQLITE_OMIT_PROGRESS_CALLBACK       1                   // Omit Progress Callback loop counter
// #define SQLITE_OMIT_SHARED_CACHE            1                   // Omit Shared Cache


// Compiler and Platform specifics

#define HAVE_FDATASYNC 1                                        // Platform has FDATASYNC
#define HAVE_GMTIME_R 1                                         // Platform has GMTIME_R
#define HAVE_LOCALTIME_S 1                                      // Platform has LOCALTIME_S
#define HAVE_USLEEP 1                                           // Platform has usleep
#define HAVE_UTIME 1                                            // Platform has utime
#define HAVE_STDINT_H 1                                         // Platform has stdint.h
#define HAVE_INTTYPES_H 1                                       // Platform has inttypes.h

#if defined(_WIN32) && defined(__GNUC__)                        // Only for GCC (MinGW on Windows)
#ifndef UNICODE_STRING_MAX_BYTES
#define UNICODE_STRING_MAX_BYTES ((WORD)65534)                  // Reset Unicode String Bytes Maximum
#endif
#ifndef UNICODE_STRING_MAX_CHARS
#define UNICODE_STRING_MAX_CHARS (32766)                        // Reset Unicode String Characters Maximum
#endif
#define HAVE_ISNAN 1                                            // Platform has isnan function
#define SQLITE_USE_MALLOC_H 1                                   // Platform has malloc.h
#define SQLITE_USE_MSIZE 1                                      // Platform malloc_usable_size is _msize
#define __USE_MINGW_ANSI_STDIO 1                                // Use ANSI StdIO
#endif

#define SQLITE_HAVE_ZLIB 1                                      // Platform has ZLIB
#define SQLITE_WIN32_USE_UUID 1                                 // Use RPCRT4 UUID Functions

#undef LONGDOUBLE_TYPE                                          // Clear the LONGDOUBLE_type

#if defined(__GNUC__) && defined(SQLITE_USE_QUADMATH)
#define LONGDOUBLE_TYPE __float128                              // Use GCC extension type if we want quadmath
#else
#undef SQLITE_USE_QUADMATH
#define LONGDOUBLE_TYPE long double                             // else long double is long double
#endif

#endif

You will note that it contains a lot of options -- some of which are compiler specific and many of which are SQLITE configuration defines. (There are also some that are no longer used and some that were experimental then removed from the code but I have been somewhat lax in removing the defunct options).

I do not see a problem with renaming the file, though I do think that having some sort of user-generated configuration header that is loaded before the rest of the code includes has benefits. Keeping it separate from what may be an automatically generated file sometimes on some platforms would be a good idea.

(12) By Larry Brasfield (larrybr) on 2021-07-08 18:15:19 in reply to 11 [link] [source]

Sounds good. As an aside, I used the "config.h" for this because (a) you do not run autoconfig on Windows and (b) it is a convenient place to put all the options which would otherwise make the command line very long (plus you can annotate it since it is a source file that can contain comments).

You describe most of the reasoning behind this change. To me, the annotation option is close to compelling.

For example, my current "config.h" that I include looks like this: [big snip]

You have published this or its predecessor here before. I have used a successor of it for quite awhile. For Windows builds, I use CL.exe's -FI... option to jam that header into the very start of the translation. For other compilers, I have used a "fake" sqlite3.c which reads: #include "local_config.h" #include "dist/sqlite3.c" . So I had little trouble seeing that direct support for this action would likely satisfy your need/desire.

I have sometimes thought that such an annotated options header, maintained to reflect all of the compilation options, ought to be in the source tree for the benefit of busy programmers who begrudge the time needed to read the docs.

(13) By David Jones (vman59) on 2021-07-08 22:12:19 in reply to 12 [link] [source]

I call my forced include file platform.h, logically it could be 2 separate files:

  • platform.h: #defines required to inform SQLite source of the build environment, so that compiling is possible.
  • features.h: #defines that enable/disable optional components of SQLite or optimize behavior.

(These are general categories, it's not always a hard line).

(14) By anonymous on 2021-12-11 19:50:16 in reply to 11 [link] [source]

Similar problem with

#define SQLITE_API=....

Also now leads to compile errors, have moved that to the project settings (using a Visual Studio Solution for VS2022...)

(15) By Larry Brasfield (larrybr) on 2021-12-11 20:36:13 in reply to 14 [link] [source]

Similar problem with

#define SQLITE_API=....

What similar problem? The post to which you nominally and putatively respond does not claim or refer to a problem. (The opposite is more the case.)

Anyway, assuming that sticking that #define in some (now mysterious) place creates a problem, why should this be considered anything but a reason not to do that? What are you trying to do that warrants attention here or possibly a fix? (And if a fix is warranted, what SQLite version do you have this problem with?)

Also now leads to compile errors, have moved that to the project settings (using a Visual Studio Solution for VS2022...)

Compile errors when doing what? (Please don't say "compiling".) Is your build setup something that the SQLite project should support, or are you just vaguely reporting some difficulty you had before tweaking that IDE?