1*4882a593Smuzhiyunutf: do not define decode() to be inline 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunCurrently, decode() is prototyped in utf.h, its body is in utf.c and it 4*4882a593Smuzhiyunis called from util.c. 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunHowever, decode() is defined to be inline, which can not work since, 7*4882a593Smuzhiyunwhen compiling util.c, the body of decode() is out-of-scope for that 8*4882a593Smuzhiyuncompilation unit. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunFurthermore, decode() uses a utf8d, which is a static defined in utf.c . 11*4882a593SmuzhiyunSo utf8d is not visible when compiling util.c either. 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunThis means that the definition of decode() along with utf8d is basically 14*4882a593Smuzhiyunwrong, and is now failing with gcc-5.x, with warnings like so: 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun libtool: compile: /home/ymorin/dev/buildroot/O/host/usr/bin/arm-linux-gcc -DHAVE_CONFIG_H -I. -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -c utf.c -fPIC -DPIC -o .libs/libwebsock_la-utf.o 17*4882a593Smuzhiyun utf.c:36:12: warning: ‘utf8d’ is static but used in inline function ‘decode’ which is not static 18*4882a593Smuzhiyun *state = utf8d[256 + *state*16 + type]; 19*4882a593Smuzhiyun ^ 20*4882a593Smuzhiyun utf.c:30:19: warning: ‘utf8d’ is static but used in inline function ‘decode’ which is not static 21*4882a593Smuzhiyun uint32_t type = utf8d[byte]; 22*4882a593Smuzhiyun ^ 23*4882a593Smuzhiyun libtool: compile: /home/ymorin/dev/buildroot/O/host/usr/bin/arm-linux-gcc -DHAVE_CONFIG_H -I. -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -c util.c -fPIC -DPIC -o .libs/libwebsock_la-util.o 24*4882a593Smuzhiyun In file included from websock.h:73:0, 25*4882a593Smuzhiyun from util.c:20: 26*4882a593Smuzhiyun utf.h:25:17: warning: inline function ‘decode’ declared but never defined 27*4882a593Smuzhiyun uint32_t inline decode(uint32_t *state, uint32_t *codep, uint32_t byte); 28*4882a593Smuzhiyun ^ 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThis results in decode() to be omitted from libwebsock.so, and thus link 31*4882a593Smuzhiyunfailures when another program wants to link with -lwebsock. 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunThe simplest solution is to not inline decode() at all. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunSigned-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun--- 38*4882a593SmuzhiyunNote: an alternative would be to move both decode() and utf8d into 39*4882a593Smuzhiyundecode.h nad ditch decode.c if decode really must be inline. This is 40*4882a593Smuzhiyunleft as an execise for an interested party. But since upstream hasn't 41*4882a593Smuzhiyunseen a single commit in more than a year now... :-( 42*4882a593Smuzhiyun 43*4882a593Smuzhiyundiff -durN a/src/utf.c b/src/utf.c 44*4882a593Smuzhiyun--- a/src/utf.c 2014-07-15 01:43:20.000000000 +0200 45*4882a593Smuzhiyun+++ b/src/utf.c 2015-08-22 22:29:38.667393786 +0200 46*4882a593Smuzhiyun@@ -24,7 +24,7 @@ 47*4882a593Smuzhiyun 1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8 48*4882a593Smuzhiyun }; 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun-uint32_t inline 51*4882a593Smuzhiyun+uint32_t 52*4882a593Smuzhiyun decode(uint32_t* state, uint32_t* codep, uint32_t byte) 53*4882a593Smuzhiyun { 54*4882a593Smuzhiyun uint32_t type = utf8d[byte]; 55*4882a593Smuzhiyundiff -durN a/src/utf.h b/src/utf.h 56*4882a593Smuzhiyun--- a/src/utf.h 2014-07-15 01:43:20.000000000 +0200 57*4882a593Smuzhiyun+++ b/src/utf.h 2015-08-22 22:29:10.439227396 +0200 58*4882a593Smuzhiyun@@ -22,7 +22,7 @@ 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #include <stdint.h> 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun-uint32_t inline decode(uint32_t *state, uint32_t *codep, uint32_t byte); 63*4882a593Smuzhiyun+uint32_t decode(uint32_t *state, uint32_t *codep, uint32_t byte); 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun #endif /* UTF_H_ */ 67