SQLite User Forum

Conflicting types when building
Login

Conflicting types when building

(1) By Mateusz (mateusz-) on 2022-08-05 12:52:42 [source]

Hello,

I would like to build SQLite for a microcontroller. I have my ARM toolchain in my extracted sqlite directory. I configure SQLite as follows:

./configure CC=arm/bin/arm-none-eabi-gcc CC_PREFIX=arm LDFLAGS="-mthumb -mabi=aapcs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -lc -lgcc -lnosys" --host="arm-none" --target="arm-none" --disable-threadsafe --disable-readline --disable-amalgamation

I then run make:

make CFLAGS="-DSQLITE_OS_OTHER=1 -DSQLITE_OMIT_DEPRECATED=1 -std=c89"

I get the following message:

/home/swengr/Projects/sqlite/sqlite/src/main.c: In function 'sqlite3_trace_v2':
/home/swengr/Projects/sqlite/sqlite/src/main.c:2170:17: warning: assignment to 'int (*)(u32,  void *, void *, void *)' {aka 'int (*)(long unsigned int,  void *, void *, void *)'} from incompatible pointer type
int (*)(unsigned int,  void *, void *, void *)' [-Wincompatible-pointer-types]
 2170 |   db->trace.xV2 = xTrace;
      |                 ^
/home/swengr/Projects/sqlite/sqlite/src/main.c: At top level:
/home/swengr/Projects/sqlite/sqlite/src/main.c:2311:5: error: conflicting types for 'sqlite3_autovacuum_pages'
 2311 | int sqlite3_autovacuum_pages(
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/swengr/Projects/sqlite/sqlite/src/sqliteInt.h:199,
                 from /home/swengr/Projects/sqlite/sqlite/src/main.c:17:
./sqlite3.h:6518:16: note: previous declaration of 'sqlite3_autovacuum_pages' was here
 6518 | SQLITE_API int sqlite3_autovacuum_pages(
      |                ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:888: main.lo] Error 1

I am using the latest release downloaded from https://www.sqlite.org/src/tarball/sqlite.tar.gz as of yesterday.

I'm guessing the solution is rather simple. Why am I getting this?

Thank you!

(2) By anonymous on 2022-08-05 20:00:16 in reply to 1 [link] [source]

Bugs in SQLite. There's an unconscious assumption that the u32 typedef always boils down to unsigned int.

Quick fix below. The real fix should probably include the creation of typedefs for callback function pointer types.

Index: src/main.c
==================================================================
--- src/main.c
+++ src/main.c
@@ -2308,11 +2308,11 @@
 ** Register a function to be invoked prior to each autovacuum that
 ** determines the number of pages to vacuum.
 */
 int sqlite3_autovacuum_pages(
   sqlite3 *db,                 /* Attach the hook to this database */
-  unsigned int (*xCallback)(void*,const char*,u32,u32,u32), 
+  unsigned int (*xCallback)(void*,const char*,unsigned,unsigned,unsigned), 
   void *pArg,                  /* Argument to the function */
   void (*xDestructor)(void*)   /* Destructor for pArg */
 ){
 #ifdef SQLITE_ENABLE_API_ARMOR
   if( !sqlite3SafetyCheckOk(db) ){

Index: src/sqliteInt.h
==================================================================
--- src/sqliteInt.h
+++ src/sqliteInt.h
@@ -1580,11 +1580,11 @@
   int nVDestroy;                /* Number of active OP_VDestroy operations */
   int nExtension;               /* Number of loaded extensions */
   void **aExtension;            /* Array of shared library handles */
   union {
     void (*xLegacy)(void*,const char*);   /* mTrace==SQLITE_TRACE_LEGACY */
-    int (*xV2)(u32,void*,void*,void*);    /* All other mTrace values */
+    int (*xV2)(unsigned,void*,void*,void*); /* All other mTrace values */
   } trace;
   void *pTraceArg;                        /* Argument to the trace function */
 #ifndef SQLITE_OMIT_DEPRECATED
   void (*xProfile)(void*,const char*,u64);  /* Profiling function */
   void *pProfileArg;                        /* Argument to profile function */