seppo0010 / rlite

self-contained, serverless, zero-configuration, transactional redis-compatible database engine. rlite is to Redis what SQLite is to SQL.
BSD 2-Clause "Simplified" License
1.06k stars 39 forks source link

Error: storage size of ‘tv’ isn’t known #40

Open quadrismegistus opened 4 years ago

quadrismegistus commented 4 years ago

I'm running into this error trying to compile rlite on Ubuntu 18:

ryan@ember:~/comrad/lib/rlite$ make all
cd src && make all
make[1]: Entering directory '/home/ryan/comrad/lib/rlite/src'
cc  -g -ggdb  -pedantic -O2 -Wall -W   -fPIC -I./ -I../deps/lua/src/ -std=c99 -c hirlite.c
hirlite.c: In function ‘debugCommand’:
hirlite.c:3433:19: error: storage size of ‘tv’ isn’t known
   struct timespec tv;
                   ^~
hirlite.c:3437:3: warning: implicit declaration of function ‘nanosleep’; did you mean ‘sleep’? [-Wimplicit-function-declaration]
   nanosleep(&tv, NULL);
   ^~~~~~~~~
   sleep
hirlite.c:3433:19: warning: unused variable ‘tv’ [-Wunused-variable]
   struct timespec tv;
                   ^~
hirlite.c: In function ‘pubsubVarargCommand’:
hirlite.c:3652:6: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable]
  int retval, i = 0, argc = c->argc - 1;
      ^~~~~~
Makefile:106: recipe for target 'hirlite.o' failed
make[1]: *** [hirlite.o] Error 1
make[1]: Leaving directory '/home/ryan/comrad/lib/rlite/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

I was able to fix it by adding the following line to the top of src/hirlite.c:

#define _POSIX_C_SOURCE 199309L

I found this fix here. Not sure if it's the best in rlite's context, but it seems to work for me:

ryan@ember:~/comrad/lib/rlite$ make all
cd src && make all
make[1]: Entering directory '/home/ryan/comrad/lib/rlite/src'
cd ../deps/lua && make ansi CFLAGS="-O2 -Wall -DENABLE_CJSON_GLOBAL -fPIC -pedantic -O2 -Wall -W   -fPIC -I./ -I../deps/lua/src/ -std=c99" MYLDFLAGS="" AR="ar rcu"
make[2]: Entering directory '/home/ryan/comrad/lib/rlite/deps/lua'
cd src && make ansi
make[3]: Entering directory '/home/ryan/comrad/lib/rlite/deps/lua/src'
make all MYCFLAGS=-DLUA_ANSI
make[4]: Entering directory '/home/ryan/comrad/lib/rlite/deps/lua/src'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/ryan/comrad/lib/rlite/deps/lua/src'
make[3]: Leaving directory '/home/ryan/comrad/lib/rlite/deps/lua/src'
make[2]: Leaving directory '/home/ryan/comrad/lib/rlite/deps/lua'
rm -f libhirlite.so
cc -shared -Wl,-soname,libhirlite.so.0.1 -o libhirlite.so  ../deps/lua/src/lapi.o ../deps/lua/src/lcode.o ../deps/lua/src/ldebug.o ../deps/lua/src/ldo.o ../deps/lua/src/ldump.o ../deps/lua/src/lfunc.o ../deps/lua/src/lgc.o ../deps/lua/src/llex.o ../deps/lua/src/lmem.o ../deps/lua/src/lobject.o ../deps/lua/src/lopcodes.o ../deps/lua/src/lparser.o ../deps/lua/src/lstate.o  ../deps/lua/src/lstring.o ../deps/lua/src/ltable.o ../deps/lua/src/ltm.o ../deps/lua/src/lundump.o ../deps/lua/src/lvm.o ../deps/lua/src/lzio.o ../deps/lua/src/strbuf.o ../deps/lua/src/fpconv.o ../deps/lua/src/lauxlib.o ../deps/lua/src/lbaselib.o ../deps/lua/src/ldblib.o ../deps/lua/src/liolib.o ../deps/lua/src/lmathlib.o ../deps/lua/src/loslib.o ../deps/lua/src/ltablib.o ../deps/lua/src/lstrlib.o ../deps/lua/src/loadlib.o ../deps/lua/src/linit.o ../deps/lua/src/lua_cjson.o ../deps/lua/src/lua_struct.o ../deps/lua/src/lua_cmsgpack.o ../deps/lua/src/lua_bit.o rlite.o page_skiplist.o page_string.o page_list.o page_btree.o page_key.o page_multi_string.o page_long.o type_string.o type_list.o type_set.o type_zset.o type_hash.o util.o restore.o dump.o sort.o pqsort.o utilfromredis.o hyperloglog.o sha1.o crc64.o lzf_c.o lzf_d.o scripting.o rand.o flock_posix.o signal_posix.o pubsub.o wal.o hirlite.o
../deps/lua/src/loslib.o: In function `os_tmpname':
loslib.c:(.text+0x290): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
make[1]: Leaving directory '/home/ryan/comrad/lib/rlite/src'

Thanks for rlite, a fantastic library!

seppo0010 commented 4 years ago

Thanks! Do you want to submit a PR?

quadrismegistus commented 4 years ago

Sure! Will do this today.