paho.mqtt.c
paho.mqtt.c copied to clipboard
Win10+cmake+mingw+mqtt-1.3.10 compile pollfd error
Describe the bug Win10+cmake+mingw+mqtt-1.3.10 compile pollfd error
Screenshots
PS E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\out1> mingw32-make.exe
Consolidate compiler generated dependencies of target common_obj
[ 1%] Building C object src/CMakeFiles/common_obj.dir/MQTTTime.c.obj
[ 3%] Building C object src/CMakeFiles/common_obj.dir/MQTTProtocolClient.c.obj
[ 4%] Building C object src/CMakeFiles/common_obj.dir/Clients.c.obj
[ 6%] Building C object src/CMakeFiles/common_obj.dir/utf-8.c.obj
[ 8%] Building C object src/CMakeFiles/common_obj.dir/MQTTPacket.c.obj
[ 9%] Building C object src/CMakeFiles/common_obj.dir/MQTTPacketOut.c.obj
[ 11%] Building C object src/CMakeFiles/common_obj.dir/Messages.c.obj
[ 12%] Building C object src/CMakeFiles/common_obj.dir/Tree.c.obj
[ 14%] Building C object src/CMakeFiles/common_obj.dir/Socket.c.obj
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'cmpfds':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:240:38: error: dereferencing pointer to incomplete type 'struct pollfd'
SOCKET key1 = ((struct pollfd*)p1)->fd;
^~
In file included from E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:45:0:
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'Socket_addSocket':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:267:63: error: invalid use of undefined type 'struct pollfd'
mod_s.fds = realloc(mod_s.fds, mod_s.nfds * sizeof(mod_s.fds[0]));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:269:51: error: invalid use of undefined type 'struct pollfd'
mod_s.fds = malloc(mod_s.nfds * sizeof(mod_s.fds[0]));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:276:11: error: invalid use of undefined type 'struct pollfd'
mod_s.fds[mod_s.nfds - 1].fd = newSd;
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:278:11: error: invalid use of undefined type 'struct pollfd'
mod_s.fds[mod_s.nfds - 1].events = POLLIN | POLLOUT;
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:278:37: error: 'POLLIN' undeclared (first use in this function); did you mean 'POINT'?
mod_s.fds[mod_s.nfds - 1].events = POLLIN | POLLOUT;
^~~~~~
POINT
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:278:37: note: each undeclared identifier is reported only once for each function it appears in
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:278:46: error: 'POLLOUT' undeclared (first use in this function); did you mean 'POLLIN'?
mod_s.fds[mod_s.nfds - 1].events = POLLIN | POLLOUT;
^~~~~~~
POLLIN
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:284:55: error: invalid use of undefined type 'struct pollfd'
qsort(mod_s.fds, (size_t)mod_s.nfds, sizeof(mod_s.fds[0]), cmpfds);
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'isReady':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:328:35: error: invalid use of undefined type 'struct pollfd'
SOCKET* socket = &mod_s.saved.fds[index].fd;
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:332:22: error: invalid use of undefined type 'struct pollfd'
if ((mod_s.saved.fds[index].revents & POLLHUP) || (mod_s.saved.fds[index].revents & POLLNVAL))
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:332:40: error: 'POLLHUP' undeclared (first use in this function)
if ((mod_s.saved.fds[index].revents & POLLHUP) || (mod_s.saved.fds[index].revents & POLLNVAL))
^~~~~~~
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:332:68: error: invalid use of undefined type 'struct pollfd'
if ((mod_s.saved.fds[index].revents & POLLHUP) || (mod_s.saved.fds[index].revents & POLLNVAL))
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:332:86: error: 'POLLNVAL' undeclared (first use in this function); did you mean 'POLLHUP'?
if ((mod_s.saved.fds[index].revents & POLLHUP) || (mod_s.saved.fds[index].revents & POLLNVAL))
^~~~~~~~
POLLHUP
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:335:20: error: invalid use of undefined type 'struct pollfd'
(mod_s.saved.fds[index].revents & POLLOUT))
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:335:38: error: 'POLLOUT' undeclared (first use in this function); did you mean 'POLLHUP'?
(mod_s.saved.fds[index].revents & POLLOUT))
^~~~~~~
POLLHUP
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:338:24: error: invalid use of undefined type 'struct pollfd'
rc = (mod_s.saved.fds[index].revents & POLLIN) &&
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:338:42: error: 'POLLIN' undeclared (first use in this function); did you mean 'POLLOUT'?
rc = (mod_s.saved.fds[index].revents & POLLIN) &&
^~~~~~
POLLOUT
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:339:21: error: invalid use of undefined type 'struct pollfd'
(mod_s.saved.fds[index].revents & POLLOUT) &&
^
In file included from E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:45:0:
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'Socket_getReadySocket':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:494:68: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds = realloc(mod_s.saved.fds, mod_s.nfds * sizeof(struct pollfd));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:496:50: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds = malloc(mod_s.nfds * sizeof(struct pollfd));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:498:58: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
memcpy(mod_s.saved.fds, mod_s.fds, mod_s.nfds * sizeof(struct pollfd));
^~~~~~
In file included from E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:31:0:
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.h:29:14: warning: implicit declaration of function 'WSAPoll'; did you mean 'WSANtohl'? [-Wimplicit-function-declaration]
#define poll WSAPoll
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:508:9: note: in expansion of macro 'poll'
*rc = poll(mod_s.saved.fds, mod_s.saved.nfds, timeout_ms);
^~~~
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:543:25: error: invalid use of undefined type 'struct pollfd'
sock = mod_s.saved.fds[mod_s.saved.cur_fd].fd;
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'Socket_close':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:918:71: error: invalid use of undefined type 'struct pollfd'
fd = bsearch(&socket, mod_s.fds, (size_t)mod_s.nfds, sizeof(mod_s.fds[0]), cmpsockfds);
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:921:38: error: invalid use of undefined type 'struct pollfd'
struct pollfd* last_fd = &mod_s.fds[mod_s.nfds - 1];
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:933:20: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds)) * sizeof(mod_s.fds[0]));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:933:43: error: arithmetic on pointer to an incomplete type
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds)) * sizeof(mod_s.fds[0]));
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:933:75: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds)) * sizeof(mod_s.fds[0]));
^
In file included from E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:45:0:
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:935:51: error: invalid use of undefined type 'struct pollfd'
mod_s.fds = realloc(mod_s.fds, sizeof(mod_s.fds[0]) * mod_s.nfds);
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c: In function 'Socket_continueWrites':
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:1314:90: error: invalid use of undefined type 'struct pollfd'
fd = bsearch(&socket, mod_s.saved.fds, (size_t)mod_s.saved.nfds, sizeof(mod_s.saved.fds[0]), cmpsockfds);
^
E:\mypt\linuxshare\mqtt\1.3.10\paho.mqtt.c-1.3.10\paho.mqtt.c-1.3.10\src\Socket.c:1316:22: error: 'POLLOUT' undeclared (first use in this function); did you mean 'PFLOAT'?
if ((fd->revents & POLLOUT) && ((rc = Socket_continueWrite(socket)) != 0))
^~~~~~~
PFLOAT
mingw32-make[2]: *** [src\CMakeFiles\common_obj.dir\build.make:187: src/CMakeFiles/common_obj.dir/Socket.c.obj] Error 1
Log files Please try to attach log files rather than pasting the log contents. It makes the issues easier to read.
** Environment (please complete the following information):**
- OS: [Windows10]
Is poll() available in this environment? I couldn't find a list of what system calls are supported. You can use the compile definition flag USE_SELECT to revert back to select() if not.
I use Windows10 Home Edition. So poll() should be available. I also tried USE_SELECT flag. But cmake+mingw does not work correctly. But i used Visual Studio 2017 to work fine.
How did you solve it?
It appears to be related to this problem https://github.com/eclipse/paho.mqtt.cpp/issues/123
Hello! I encountered the same error on Windows 10 + MinGW 8.1.0 64-bit + CMake 3.24.2, I'm using MQTTAsync client, from paho.mqtt.c-1.3.13.
CMakeLists.txt:
set(PAHO_BUILD_SHARED FALSE)
set(PAHO_BUILD_STATIC TRUE)
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/paho/paho.mqtt.c-1.3.13/
my_app__paho_mqtt_c
EXCLUDE_FROM_ALL
)
add_executable(my_app
${MY_APP_HEADERS} ${MY_APP_SOURCES}
)
target_link_libraries(my_app
PRIVATE
# paho-mqtt3c # SYNC client
paho-mqtt3a # ASYNC client
)
MinGW Build errors
[79/300 66.4/sec] Building C object my_app__paho_mqtt_c/src/CMakeFiles/common_obj_static.dir/Socket.c.obj
FAILED: my_app__paho_mqtt_c/src/CMakeFiles/common_obj_static.dir/Socket.c.obj
C:\Qt\Tools\mingw810_64\bin\gcc.exe -DPAHO_MQTT_STATIC=1 -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -g -fdiagnostics-color=always -MD -MT my_app__paho_mqtt_c/src/CMakeFiles/common_obj_static.dir/Socket.c.obj -MF my_app__paho_mqtt_c\src\CMakeFiles\common_obj_static.dir\Socket.c.obj.d -o my_app__paho_mqtt_c/src/CMakeFiles/common_obj_static.dir/Socket.c.obj -c path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'cmpfds':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:248:38: error: dereferencing pointer to incomplete type 'struct pollfd'
SOCKET key1 = ((struct pollfd*)p1)->fd;
^~
In file included from path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:45:
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'Socket_addSocket':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:276:78: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_read = realloc(mod_s.fds_read, mod_s.nfds * sizeof(mod_s.fds_read[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:278:61: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_read = malloc(mod_s.nfds * sizeof(mod_s.fds_read[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:285:81: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_write = realloc(mod_s.fds_write, mod_s.nfds * sizeof(mod_s.fds_write[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:287:63: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_write = malloc(mod_s.nfds * sizeof(mod_s.fds_write[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:294:16: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_read[mod_s.nfds - 1].fd = newSd;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:295:17: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_write[mod_s.nfds - 1].fd = newSd;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:297:16: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_read[mod_s.nfds - 1].events = POLLIN;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:297:42: error: 'POLLIN' undeclared (first use in this function); did you mean 'POINT'?
mod_s.fds_read[mod_s.nfds - 1].events = POLLIN;
^~~~~~
POINT
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:297:42: note: each undeclared identifier is reported only once for each function it appears in
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:298:17: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_write[mod_s.nfds - 1].events = POLLOUT;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:298:43: error: 'POLLOUT' undeclared (first use in this function); did you mean 'PFLOAT'?
mod_s.fds_write[mod_s.nfds - 1].events = POLLOUT;
^~~~~~~
PFLOAT
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:305:65: error: invalid use of undefined type 'struct pollfd'
qsort(mod_s.fds_read, (size_t)mod_s.nfds, sizeof(mod_s.fds_read[0]), cmpfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:306:67: error: invalid use of undefined type 'struct pollfd'
qsort(mod_s.fds_write, (size_t)mod_s.nfds, sizeof(mod_s.fds_write[0]), cmpfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'isReady':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:351:41: error: invalid use of undefined type 'struct pollfd'
SOCKET* socket = &mod_s.saved.fds_write[index].fd;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:355:27: error: invalid use of undefined type 'struct pollfd'
if ((mod_s.saved.fds_read[index].revents & POLLHUP) || (mod_s.saved.fds_read[index].revents & POLLNVAL))
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:355:45: error: 'POLLHUP' undeclared (first use in this function)
if ((mod_s.saved.fds_read[index].revents & POLLHUP) || (mod_s.saved.fds_read[index].revents & POLLNVAL))
^~~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:355:78: error: invalid use of undefined type 'struct pollfd'
if ((mod_s.saved.fds_read[index].revents & POLLHUP) || (mod_s.saved.fds_read[index].revents & POLLNVAL))
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:355:96: error: 'POLLNVAL' undeclared (first use in this function); did you mean 'PTIMEVAL'?
if ((mod_s.saved.fds_read[index].revents & POLLHUP) || (mod_s.saved.fds_read[index].revents & POLLNVAL))
^~~~~~~~
PTIMEVAL
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:358:26: error: invalid use of undefined type 'struct pollfd'
(mod_s.saved.fds_write[index].revents & POLLOUT))
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:358:44: error: 'POLLOUT' undeclared (first use in this function); did you mean 'PFLOAT'?
(mod_s.saved.fds_write[index].revents & POLLOUT))
^~~~~~~
PFLOAT
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:361:29: error: invalid use of undefined type 'struct pollfd'
rc = (mod_s.saved.fds_read[index].revents & POLLIN) &&
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:361:47: error: 'POLLIN' undeclared (first use in this function); did you mean 'POINT'?
rc = (mod_s.saved.fds_read[index].revents & POLLIN) &&
^~~~~~
POINT
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:362:27: error: invalid use of undefined type 'struct pollfd'
(mod_s.saved.fds_write[index].revents & POLLOUT) &&
^
In file included from path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:45:
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'Socket_getReadySocket':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:528:78: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds_read = realloc(mod_s.saved.fds_read, mod_s.nfds * sizeof(struct pollfd));
^~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:530:55: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds_read = malloc(mod_s.nfds * sizeof(struct pollfd));
^~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:541:80: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds_write = realloc(mod_s.saved.fds_write, mod_s.nfds * sizeof(struct pollfd));
^~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:543:56: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
mod_s.saved.fds_write = malloc(mod_s.nfds * sizeof(struct pollfd));
^~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:41:48: note: in definition of macro 'malloc'
#define malloc(x) mymalloc(__FILE__, __LINE__, x)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:548:69: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
memcpy(mod_s.saved.fds_read, mod_s.fds_read, mod_s.nfds * sizeof(struct pollfd));
^~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:552:71: error: invalid application of 'sizeof' to incomplete type 'struct pollfd'
memcpy(mod_s.saved.fds_write, mod_s.fds_write, mod_s.nfds * sizeof(struct pollfd));
^~~~~~
In file included from path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:31:
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.h:29:14: warning: implicit declaration of function 'WSAPoll'; did you mean 'WSANtohl'? [-Wimplicit-function-declaration]
#define poll WSAPoll
^~~~~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:561:9: note: in expansion of macro 'poll'
rc1 = poll(mod_s.saved.fds_write, mod_s.saved.nfds, 0);
^~~~
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:599:30: error: invalid use of undefined type 'struct pollfd'
sock = mod_s.saved.fds_read[mod_s.saved.cur_fd].fd;
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'Socket_close':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:978:81: error: invalid use of undefined type 'struct pollfd'
fd = bsearch(&socket, mod_s.fds_read, (size_t)mod_s.nfds, sizeof(mod_s.fds_read[0]), cmpsockfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:981:43: error: invalid use of undefined type 'struct pollfd'
struct pollfd* last_fd = &mod_s.fds_read[mod_s.nfds - 1];
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:993:20: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_read)) * sizeof(mod_s.fds_read[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:993:43: error: arithmetic on pointer to an incomplete type
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_read)) * sizeof(mod_s.fds_read[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:993:85: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_read)) * sizeof(mod_s.fds_read[0]));
^
In file included from path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:45:
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:995:66: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_read = realloc(mod_s.fds_read, sizeof(mod_s.fds_read[0]) * mod_s.nfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1007:87: error: invalid use of undefined type 'struct pollfd'
fd = bsearch(&socket, mod_s.fds_write, (size_t)(mod_s.nfds+1), sizeof(mod_s.fds_write[0]), cmpsockfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1010:44: error: invalid use of undefined type 'struct pollfd'
struct pollfd* last_fd = &mod_s.fds_write[mod_s.nfds];
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1022:20: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_write)) * sizeof(mod_s.fds_write[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1022:43: error: arithmetic on pointer to an incomplete type
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_write)) * sizeof(mod_s.fds_write[0]));
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1022:87: error: invalid use of undefined type 'struct pollfd'
memmove(fd, fd + 1, (mod_s.nfds - (fd - mod_s.fds_write)) * sizeof(mod_s.fds_write[0]));
^
In file included from path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:45:
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1024:69: error: invalid use of undefined type 'struct pollfd'
mod_s.fds_write = realloc(mod_s.fds_write, sizeof(mod_s.fds_write[0]) * mod_s.nfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Heap.h:49:56: note: in definition of macro 'realloc'
#define realloc(a, b) myrealloc(__FILE__, __LINE__, a, b)
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c: In function 'Socket_continueWrites':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1414:102: error: invalid use of undefined type 'struct pollfd'
fd = bsearch(&socket, mod_s.saved.fds_write, (size_t)mod_s.saved.nfds, sizeof(mod_s.saved.fds_write[0]), cmpsockfds);
^
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/Socket.c:1416:22: error: 'POLLOUT' undeclared (first use in this function); did you mean 'PFLOAT'?
if ((fd->revents & POLLOUT) && ((rc = Socket_continueWrite(socket)) != 0))
^~~~~~~
PFLOAT
After adding poll() --> select() fix, everything worked for me:
set(PAHO_BUILD_SHARED FALSE)
set(PAHO_BUILD_STATIC TRUE)
if(MINGW)
# On Windows+MinGW 'poll()' is not supported, we need to use 'select()'
# Reference: https://github.com/eclipse/paho.mqtt.c/issues/1239
set(PAHO_USE_SELECT TRUE)
endif()
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/paho/paho.mqtt.c-1.3.13/
my_app__paho_mqtt_c
EXCLUDE_FROM_ALL
)
But during paho.mqtt.c build, I see the next warning:
[291/300 34.5/sec] Building C object my_app__paho_mqtt_c/src/CMakeFiles/paho-mqtt3a-static.dir/MQTTAsync.c.obj
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/MQTTAsync.c: In function 'MQTTAsync_createWithOptions':
path/to/third_party/paho/paho.mqtt.c-1.3.13/src/MQTTAsync.c:305:17: warning: implicit declaration of function 'InitOnceExecuteOnce'; did you mean 'InitMutexesOnce'? [-Wimplicit-function-declaration]
BOOL bStatus = InitOnceExecuteOnce(&g_InitOnce, InitMutexesOnce, NULL, NULL);
^~~~~~~~~~~~~~~~~~~
InitMutexesOnce
https://github.com/eclipse/paho.mqtt.c/blob/6b1e202a701ffcdaa277b5644ed291287a70a7aa/src/MQTTAsync.c#L303-L306
This case does not affect the operation of my program (since I dont call MQTTAsync_createWithOptions) in any way, but I think the defines need to be updated here.