Skip to content

Commit

Permalink
Merge pull request #504 from myd7349/master
Browse files Browse the repository at this point in the history
Define srandom and random for WIN32
  • Loading branch information
hintjens committed Jan 16, 2015
2 parents 8f222cf + a0711df commit b97d0b4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/C/zhelpers.h
Expand Up @@ -32,13 +32,15 @@
# error "Please upgrade to ZeroMQ/3.2 for these examples"
#endif

// Provide random number from 0..(num-1)
// On some version of Windows, POSIX subsystem is not installed by default.
// So define srandom and random ourself.
#if (defined (WIN32))
# define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0))
#else
# define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
# define srandom srand
# define random rand
#endif

// Provide random number from 0..(num-1)
#define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))

// Receive 0MQ string from socket and convert into C string
// Caller must free returned string. Returns NULL if the context
Expand Down

0 comments on commit b97d0b4

Please sign in to comment.