SQLite Forum

SQLITE_OS_WIN definition location
Login

SQLITE_OS_WIN definition location

(1) By markstz on 2021-06-18 06:50:51 [source]

In the amalgamation file sqlite3.c, when compiled on Windows, SQLITE_OS_WIN is defined on line 16426 (in 3.35.0). But it's referenced earlier on line 13896 and again on 13912.

#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
  extern int sqlite3OSTrace;
# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
# define SQLITE_HAVE_OS_TRACE
#else
# define OSTRACE(X)
# undef  SQLITE_HAVE_OS_TRACE
#endif

On Windows, this should enable OSTRACE if SQLITE_DEBUG is defined as a compiler option, but it only works if SQLITE_OS_WIN is explicitly defined too.

I thought SQLITE_OS_WIN is not supposed to be defined as a compiler option, as sqlite3.c does it on Windows if SQLITE_OS_OTHER is not defined.

Is there an error here?

(2) By Larry Brasfield (larrybr) on 2021-06-18 16:46:51 in reply to 1 [link] [source]

I agree that this ordering is a little odd. As it only affects debug builds and a release is imminent, don't expect to see this fixed soon. I believe the Makefile.msc (for Windows targets) sets this explicitly, so that has helped disguise this issue for a long time.

(3) By markstz on 2023-01-09 14:01:46 in reply to 2 [link] [source]

This error is still present in 3.40.1.

(4) By mistachkin on 2023-01-09 17:14:14 in reply to 1 [link] [source]

The Makefiles for Windows always define SQLITE_OS_WIN so this is never a
real issue.

(5) By markstz on 2023-01-12 11:59:13 in reply to 4 [link] [source]

It is an issue when you're building SQLite directly into a project, and not using it via a library or DLL, and so are not using the Windows makefiles.

If the code is deemed correct then the documentation is wrong. Nowhere does it say you have to define SQLITE_OS_WIN to build SQLite on Windows.

(6) By mistachkin on 2023-01-12 15:49:12 in reply to 5 [link] [source]

The debugger reference to SQLITE_OS_WIN that you posted is generally only
intended to be used with the MSVC makefile.