uSockets
uSockets copied to clipboard
tests/sni_test.c fails to compile: error: expected identifier or '('
clang-11 complains:
===> Testing for usockets-0.8.0
cd /disk-samsung/freebsd-ports/net/usockets/work/uSockets-0.8.0 && cc -o test tests/sni_test.c /disk-samsung/freebsd-ports/net/usockets/work/stage/usr/local/lib/libuSockets.so
tests/sni_test.c:1:8: error: expected identifier or '('
extern "C" {
^
tests/sni_test.c:22:14: warning: implicit declaration of function 'sni_new' is invalid in C99 [-Wimplicit-function-declaration]
void *sni = sni_new();
^
tests/sni_test.c:22:8: warning: incompatible integer to pointer conversion initializing 'void *' with an expression of type 'int' [-Wint-conversion]
void *sni = sni_new();
^ ~~~~~~~~~
tests/sni_test.c:25:9: warning: implicit declaration of function 'sni_add' is invalid in C99 [-Wimplicit-function-declaration]
assert(sni_add(sni, "*.google.com", 13) == 0);
^
tests/sni_test.c:30:9: warning: implicit declaration of function 'sni_find' is invalid in C99 [-Wimplicit-function-declaration]
assert(sni_find(sni, "anything.google.com") == 13);
^
tests/sni_test.c:39:9: warning: implicit declaration of function 'sni_remove' is invalid in C99 [-Wimplicit-function-declaration]
assert(sni_remove(sni, "test.google.com") == 14);
^
tests/sni_test.c:54:2: warning: implicit declaration of function 'sni_free' is invalid in C99 [-Wimplicit-function-declaration]
sni_free(sni, sni_free_cb);
^
6 warnings and 1 error generated.
*** Error code 1
Running the C++ compiler on this C source also fails:
===> Testing for usockets-0.8.0
cd /disk-samsung/freebsd-ports/net/usockets/work/uSockets-0.8.0 && c++ -o test tests/sni_test.c /disk-samsung/freebsd-ports/net/usockets/work/stage/usr/local/lib/libuSockets.so
c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
tests/sni_test.c:25:9: error: no matching function for call to 'sni_add'
assert(sni_add(sni, "*.google.com", 13) == 0);
^~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:4:5: note: candidate function not viable: no known conversion from 'int' to 'void *' for 3rd argument
int sni_add(void *sni, const char *hostname, void *user);
^
tests/sni_test.c:26:9: error: no matching function for call to 'sni_add'
assert(sni_add(sni, "test.google.com", 14) == 0);
^~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:4:5: note: candidate function not viable: no known conversion from 'int' to 'void *' for 3rd argument
int sni_add(void *sni, const char *hostname, void *user);
^
tests/sni_test.c:29:9: error: no matching function for call to 'sni_add'
assert(sni_add(sni, "*.google.com", 15) != 0);
^~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:4:5: note: candidate function not viable: no known conversion from 'int' to 'void *' for 3rd argument
int sni_add(void *sni, const char *hostname, void *user);
^
tests/sni_test.c:30:46: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "anything.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:32:42: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "docs.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:33:39: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "*.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:34:42: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "test.google.com") == 14);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:36:42: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "yolo.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:39:44: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_remove(sni, "test.google.com") == 14);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:40:42: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "test.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:41:41: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_remove(sni, "*.google.com") == 13);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:45:9: error: no matching function for call to 'sni_add'
assert(sni_add(sni, "www.google.com", 16) == 0);
^~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:4:5: note: candidate function not viable: no known conversion from 'int' to 'void *' for 3rd argument
int sni_add(void *sni, const char *hostname, void *user);
^
tests/sni_test.c:46:9: error: no matching function for call to 'sni_add'
assert(sni_add(sni, "www.google.com.au.ck.uk", 17) == 0);
^~~~~~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:4:5: note: candidate function not viable: no known conversion from 'int' to 'void *' for 3rd argument
int sni_add(void *sni, const char *hostname, void *user);
^
tests/sni_test.c:47:41: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "www.google.com") == 16);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:48:50: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "www.google.com.au.ck.uk") == 17);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:50:52: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_remove(sni, "www.google.com.au.ck.uk") == 17);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
tests/sni_test.c:51:41: error: comparison between pointer and integer ('void *' and 'int')
assert(sni_find(sni, "www.google.com") == 16);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
/usr/include/assert.h:56:21: note: expanded from macro 'assert'
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
^
17 errors generated.
*** Error code 1
FreeBSD 13
Remove the extern "C" part from the top and compile as C.
Can you remove extern "C" in the repository?
After it is removed there are still valid warnings:
warning: comparison between pointer and integer ('void *' and 'int') [-Wpointer-integer-compare]
and the test executable crashes.
It would also be nice if tests were run by the test target.