-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use facil.io to communicate with a wss server in embedded system? #74
Comments
Hi @Sarah-Wang. Thank you for your question. I believe facil.io would be a good choice for a C based WebSocket client on an embedded system. I didn't test facil.io on embedded systems, but I did my best to keep the code portable, so it should work in different POSIX environments (such as embedded Linux). Although there's an HTTP client example, there's no WebSocket client example in the facil.io repo. A generic, slightly more advance, WebSocket client was programmed into the iodine Ruby server using facil.io, maybe you could use that code as an example. Also, please note that there are some specific considerations for embedded systems that relate to the fact that you will have limited resources (less memory, etc'). You would need to explore many of the compilation flags and runtime settings to minimize memory usage. For example, you might want to compile facil.io with This is especially true when using facil.io only as a client to a single remote server (even then, it's important that Compilation flags can be easily added to the makefile. For example: FLAGS:=FIO_MAX_SOCK_CAPACITY=16 HTTP_BUSY_UNLESS_HAS_FDS=0 Since you're only using client mode, you might not need the default mime type registry. It will just take memory and could probably be safely removed. Depending how limited your memory is, you might want to avoid or make some changes to the custom memory allocator, since it will reserve 8Mb of memory per CPU core, which might be more then you need. Consider (though it will make things slower): FLAGS:=FIO_MAX_SOCK_CAPACITY=32 FIO_FORCE_MALLOC Some runtime flags will also be important to make sure the WebSocket connection doesn't use too much memory. For example, the Please let me know how it goes and if there's anything I can do to help make facil.io more suited to embedded systems. Good luck! Kindly, |
Thank you very much for your kind help! |
I would like to try it on my Ubuntu system firstly, and make sure the whole process is OK. The source file is : boazsegev-facil.io-0.7.2-0-gef041d9.tar.gz sarah@Ubuntu1404:~/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/build$ make
Scanning dependencies of target facil.io
[ 5%] Building C object CMakeFiles/facil.io.dir/lib/facil/fio.o
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:8:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_risky_hash’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:2477:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = len >> 5; i; --i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:2477:3: note: use option -std=c99 or -std=gnu99 to compile your code
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:136:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_uuid_links_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6028:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = s->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_uuid_links_rehash’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6294:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = set->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_clear_fd’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:330:5: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&links, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_local_addr’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:486:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (struct addrinfo *pos = info; pos; pos = pos->ai_next) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_defer_thread_pool_join’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1106:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < pool->thread_count; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_defer_thread_pool_new’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1120:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < count; ++i) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_timer_add_order’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1237:3: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&fio_timers, node) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_poll_close’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1639:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < 3; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_poll_init’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1649:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < 3; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1654:12: error: redefinition of ‘i’
for (int i = 1; i < 3; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1649:12: note: previous definition of ‘i’ was here
for (int i = 0; i < 3; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1654:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 1; i < 3; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_poll’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1729:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int j = 0; j < internal_count; ++j) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:1733:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < active_count; i++) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_tcp_socket’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:2509:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (struct addrinfo *i = addrinfo; i != NULL; i = i->ai_next) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:2536:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (struct addrinfo *i = addrinfo; i; i = i->ai_next) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_flush_all’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3056:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (uintptr_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_state_callback_remove’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3344:3: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_state_callback_force’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3375:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3384:61: error: redefinition of ‘pos’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:23: note: in definition of macro ‘FIO_LS_EMBD_FOR’
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3375:61: note: previous definition of ‘pos’ was here
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:23: note: in definition of macro ‘FIO_LS_EMBD_FOR’
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3384:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3398:61: error: redefinition of ‘pos’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:23: note: in definition of macro ‘FIO_LS_EMBD_FOR’
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3384:61: note: previous definition of ‘pos’ was here
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:23: note: in definition of macro ‘FIO_LS_EMBD_FOR’
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3398:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&callback_collection[c_type].callbacks, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_state_callback_on_fork’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3435:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < (FIO_CALL_NEVER + 1); ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_state_callback_clear_all’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3440:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < (FIO_CALL_NEVER + 1); ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_on_fork’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3512:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < limit; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_lib_init’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3627:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (ssize_t i = 0; i < capa; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_worker_cleanup’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3802:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3809:15: error: redefinition of ‘i’
for (size_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3802:15: note: previous definition of ‘i’ was here
for (size_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3809:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i <= fio_data->max_protocol_fd; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_start’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:3933:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < args.workers && fio_data->active; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_listen_on_data’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:4522:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < 4; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_listen_on_data_tls’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:4532:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < 4; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_listen_on_data_tls_alpn’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:4543:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 0; i < 4; ++i) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5178:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_ch_set_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6028:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = s->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_ch_set_rehash’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6294:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = set->ordered; pos < end; ++pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5183:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_meta_ary_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:4892:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = ary->start; i < count; ++i) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5189:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_engine_set_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6028:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = s->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_engine_set_rehash’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6294:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = set->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_pubsub_on_channel_create’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5537:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.engines.set, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_pubsub_on_channel_destroy’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5551:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.engines.set, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_pubsub_reattach’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5614:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5624:55: error: redefinition of ‘pos’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5614:53: note: previous definition of ‘pos’ was here
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5624:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_publish2channel’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5741:3: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&ch->subscriptions, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5189:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_publish2process’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5788:5: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, p) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5822:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_sub_hash_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6028:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = s->ordered; pos < end; ++pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h: In function ‘fio_sub_hash_rehash’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:6294:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (FIO_NAME(_ordered_s_) *pos = set->ordered; pos < end; ++pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_cluster_on_close’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3346:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_s *pos = (list)->next; pos != (list); pos = pos->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6028:5: note: in expansion of macro ‘FIO_LS_FOR’
FIO_LS_FOR(&cluster_data.clients, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_cluster_server_sender’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3346:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_s *pos = (list)->next; pos != (list); pos = pos->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6084:3: note: in expansion of macro ‘FIO_LS_FOR’
FIO_LS_FOR(&cluster_data.clients, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5822:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_cluster_on_connect’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6288:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6296:55: error: redefinition of ‘pos’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6288:53: note: previous definition of ‘pos’ was here
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6296:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_pubsub_on_fork’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6469:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.filters.channels, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6473:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&pos->obj->subscriptions, n) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5822:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6477:53: error: redefinition of ‘pos’
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6469:54: note: previous definition of ‘pos’ was here
FIO_SET_FOR_LOOP(&fio_postoffice.filters.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6477:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6481:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&pos->obj->subscriptions, n) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:5822:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6485:55: error: redefinition of ‘pos’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6477:53: note: previous definition of ‘pos’ was here
FIO_SET_FOR_LOOP(&fio_postoffice.pubsub.channels, pos) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:35: note: in definition of macro ‘FIO_SET_FOR_LOOP’
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:5839:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (__typeof__((set)->ordered) container = (set)->ordered; \
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6485:3: note: in expansion of macro ‘FIO_SET_FOR_LOOP’
FIO_SET_FOR_LOOP(&fio_postoffice.patterns.channels, pos) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:6489:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&pos->obj->subscriptions, n) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘arena_lock’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7059:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = (size_t)(arena - arenas); i < memory.cores; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_malloc_after_fork’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7085:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < memory.cores; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘block_free’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7134:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < FIO_MEMORY_BLOCKS_PER_ALLOCATION; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘block_new’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7171:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i = 1; i < FIO_MEMORY_BLOCKS_PER_ALLOCATION; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_mem_destroy’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7312:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < memory.cores; ++i) {
^
In file included from /home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:15:0:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.h:3288:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (fio_ls_embd_s *node = (list)->next; node != (list); node = node->next)
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7322:5: note: in expansion of macro ‘FIO_LS_EMBD_FOR’
FIO_LS_EMBD_FOR(&memory.available, node) { ++count; }
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_rand_bytes’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7487:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = (len >> 5); i; --i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c: In function ‘fio_siphash_xy’:
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7616:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < x; ++i) {
^
/home/sarah/ws_test/facil.io/wsapp/boazsegev-facil.io-ef041d9/lib/facil/fio.c:7657:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < y; ++i) {
^
make[2]: *** [CMakeFiles/facil.io.dir/lib/facil/fio.o] Error 1
make[1]: *** [CMakeFiles/facil.io.dir/all] Error 2
make: *** [all] Error 2 |
The facil.io library requires C99. From the errors, it appears your compiler either doesn't support C99 or was instructed to use an earlier draft (such as, perhaps, ANSI C?). Which compiler are you using? Also, on a more personal preference / note: I don't use CMake, I use GNU make. The CMake support isn't regularly tested (it was added by someone else who tested it). |
Thank you for your help! |
I want to use c code in embedded linux system to communicate with a thirdparty websocket server by wss protocol. Would facil.io be a good choice? Is there any completed example of how to realize that function?
Thank you very much!
The text was updated successfully, but these errors were encountered: