On Oct 25, 2008, at 11:40 PM, William Kyngesburye wrote: > I added rtree to my sqlite compilation for the first time and got > these warnings for OSX 64bit: > > /Users/Shared/src/sqlite/sqlite-3.6.4/sqlite3.c: In function > ‘rtreeCreate’: > /Users/Shared/src/sqlite/sqlite-3.6.4/sqlite3.c:94784: warning: cast > from pointer to integer of different size > /Users/Shared/src/sqlite/sqlite-3.6.4/sqlite3.c: In function > ‘rtreeConnect’: > /Users/Shared/src/sqlite/sqlite-3.6.4/sqlite3.c:94797: warning: cast > from pointer to integer of different size > > These are in the rtreeCreate() and rtreeConnect() functions, calling > rtreeInit(): > > return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1, (int)pAux); > > I thought the two pAux parameters were odd - one bare and one cast to > (int), so I looked up rtreeInit().
Good point. I removed the first of the two "pAux" parameters from rtreeInit(). It was not being used. http://www.sqlite.org/cvstrac/chngview?cn=5842 > static int rtreeInit(sqlite3 *db, void *pAux, int argc, const char > *const*argv, sqlite3_vtab **ppVtab, char **pzErr, int isCreate, int > eCoordType) > > The first pAux is a pointer, so this one looks correct. But the > second is an int (eCoordType), and the only two values I found defined > are 0 & 1: > > #define RTREE_COORD_REAL32 0 > #define RTREE_COORD_INT32 1 > > Forget the cast warnings now - why is pAux used to set the > eCoordType? My C skills are pretty basic, so maybe there is some > pointer/cast magic happening? Or maybe it's simply screwed up? The two functions that call rtreeInit() are registered as callbacks with SQLite. When you register the callback function you also specify a void* pointer that is passed to the callback whenever it is invoked. This is not an uncommon pattern in C code. So, since the interface allows us to pass a void* as context to the callback function, but in this instance we really just want an integer, the value has to be cast to a void* when the callback function is registered, and back to an integer when the callback is invoked. A lot of compilers throw a warning when they encounter this. In my opinion (having never had anything to do with compiler design or implementation) they shouldn't. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users