On Fri, 04 Feb 2005 16:54:31 -0500, Kervin L. Pierre
<[EMAIL PROTECTED]> wrote:
> Thanks for your response Chris.
>
> Is there a way to find out what components are
> compiled in at runtime?
>
I don't believe the way the THREADSAFE define is handled today would
allow you to check anything at run-time. I sent the following patch to
the mailing list just yesterday. I got a goofy bounce message, but I
thought the message had been sent to the list, but nobody's commented,
so maybe it never made it... :)
This patch will enable sqlite thread safe processing on windows with
the MSVC compiler, if the symbol _MT is defined. IMHO, this is a
better way to handle this, since it's automatic.
--- os_win.c 17 Nov 2004 00:21:38 -0000 1.1
+++ os_win.c 4 Feb 2005 04:10:02 -0000 1.2
@@ -21,6 +21,16 @@
/*
** Macros used to determine whether or not to use threads.
*/
+#if defined(_MSC_VER)
+# if defined(_MT)
+# define SQLITE_W32_THREADS 1
+# pragma message("sqlite3 thread-safe support enabled.")
+# else
+# undef SQLITE_W32_THREADS
+# pragma message("sqlite3 thread-safe support disabled.")
+# endif
+#endif
+
#if defined(THREADSAFE) && THREADSAFE
# define SQLITE_W32_THREADS 1
#endif
> I built sqlite myself and I did turn on that
> macro, but I want to double check everything
> at runtime. Maybe throw an error if
> multi-threading support is not available in
> the DLL.
>
The way THREADSAFE works currently, is that it must be defined, but
also must have a value assigned to it. The compiler switch /D
THREADSAFE won't cause sqlite to have thread safe code included, whiel
/D THREADSAFE=1 will. Ensure you're using the latter format, or
alternatively, us the patch I posted to have this detected
automatically when you're doing a multi-threaded build in MSVC vs.
single-threaded.
> Is there a way to detect multi-threading
> support at runtime?
>
You could do something like:
#if defined(THREADSAFE) && THREADSAFE
int g_isThreadSafe = 1;
#else
int g_isThreadSafe = 0;
#endif
and then check g_isThreadSafe in your code at run-time.
Hope that helps.
--
Jeff Thompson
[EMAIL PROTECTED]