Which C standard does Sqlite's source code compatible?
(1) By anonymous on 2020-06-29 09:54:13 [link] [source]
Hey,
I just want to know which C standard (I guess C99?) does sqlite's code compatible?
(2) By Stephan Beal (stephan) on 2020-06-29 09:58:26 in reply to 1 [link] [source]
I just want to know which C standard (I guess C99?) does sqlite's code compatible?
It's mostly C89 compatible, but at least one construct (long long
) is not strictly C89 but is supported in non-strict C89 mode on all (or almost all) known compilers. It does not require any C standard published this century.
(3) By anonymous on 2020-06-29 10:02:31 in reply to 2 [link] [source]
Ok, thank you for your reply.
(4) By Warren Young (wyoung) on 2020-06-29 20:59:31 in reply to 2 [link] [source]
The official statement says C99 without qualifications.
(5.1) By Keith Medcalf (kmedcalf) on 2020-06-29 21:41:48 edited from 5.0 in reply to 4 [source]
Deleted(6) By Keith Medcalf (kmedcalf) on 2020-06-29 21:44:56 in reply to 4 [link] [source]
The minimum appears to be gnu89 and/or c99.
That is, with GCC -std=gnu89 (or later) works, as does -std=c99 (or later).
(7) By Keith Medcalf (kmedcalf) on 2020-06-29 21:54:00 in reply to 4 [link] [source]
The minimum appears to be gnu89 and/or c99.
That is, with GCC -std=gnu89 (or later) works, as does -std=c99 (or later).
(8.1) By Stephan Beal (stephan) on 2020-07-01 15:26:20 edited from 8.0 in reply to 7 [link] [source]
For completeness's sake: the sqlite3 amalgamation compiles fine with gcc using -std=c89 -Wall -Werror -Wextra -Wpedantic
, so long as a couple other flags are passed along with it:
-Wno-long-long
because C89/C90 doesn't specify long long.-Wno-implicit-fallthrough
because gcc's devs broke a great many real-world builds when they "deprecated" implicit switch fall-through. Grrrrrrr.
e.g.:
gcc -g -Wpedantic -Werror -Wall -Wextra \
-Wsign-compare -fPIC -std=c89 -Wno-long-long \
-Wno-implicit-fallthrough \
-c -o sqlite3.o sqlite3.c
Edit: depending on the build options and gcc version, it may also need:
-Wno-cast-function-type
because sqlite apparently casts between (void (*)(void)
) and (int (*)(void)
)-Wno-unused-parameter
for interface-level parameters which may not be used by certain concrete implementations of the interface.