SQLite Forum

SQLITE_OS_WIN definition location
Login

SQLITE_OS_WIN definition location

(1) By markstz on 2021-06-18 06:50:51 [link] [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 [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.