[zeromq-dev] zhelpers.hpp can not be compiled under Windows
Oleg Vazhnev
ovazhnev at gmail.com
Sun May 12 09:32:54 CEST 2013
Hi
I'm trying to run pub-sub example on Windows.
I've run succesfully wuserver / wuclient example, but by some reason it
doesn't work (i just do not receive items).
So I've decided to try syncpub / syncsub example, but they require
zhelpers.hpp file:
https://github.com/imatix/zguide/blob/master/examples/C%2B%2B/zhelpers.hpp
It seems this file is kind of ready to be run under Windows, most part
of the system calls are surrounded with #ifdef, like this one:
#if (defined (__WINDOWS__))
SYSTEMTIME st;
GetSystemTime (&st);
return (int64_t) st.wSecond * 1000 + st.wMilliseconds;
#else
struct timeval tv;
gettimeofday (&tv, NULL);
return (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000);
#endif
However I still have several compile errors on these lines:
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
static void s_catch_signals ()
{
struct sigaction action;
Also this macro should be changed:
#define within(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
Because under Windows "random" should be "rand"
==============================================================
I've commented "s_catch_signals" function and corresonding includes,
fixed macro (random => rand) and code compiles.
So it seems while entire file is platform-independent, "s_catch_signals"
function is Linux-only. I guess probably it's better to move it to
another place. Then examples will compile under Windows.
Thanks,
Oleg
More information about the zeromq-dev
mailing list