Fix Windows builds (rand/random API)

This commit is contained in:
Robin Gareus 2021-08-14 01:07:13 +02:00
parent 79baf356b9
commit fc90c92a49
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 19 additions and 1 deletions

View File

@ -19,6 +19,10 @@ using namespace Gtk;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
#ifdef PLATFORM_WINDOWS
#define srandom() srand()
#endif
int int
main (int argc, char* argv[]) main (int argc, char* argv[])
{ {

View File

@ -21,6 +21,10 @@ using namespace Gtk;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
#ifdef PLATFORM_WINDOWS
#define srandom() srand()
#endif
#define SQUARED 16 #define SQUARED 16
struct Column { struct Column {

View File

@ -19,6 +19,10 @@ using namespace Gtk;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
#ifdef PLATFORM_WINDOWS
#define srandom() srand()
#endif
int int
main (int argc, char* argv[]) main (int argc, char* argv[])
{ {

View File

@ -19,6 +19,10 @@ using namespace Gtk;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
#ifdef PLATFORM_WINDOWS
#define srandom() srand()
#endif
int int
main (int argc, char* argv[]) main (int argc, char* argv[])
{ {

View File

@ -23,6 +23,8 @@
#include <cfloat> #include <cfloat>
#include <cstdlib> #include <cstdlib>
#include <glib.h>
#include "pbd/failed_constructor.h" #include "pbd/failed_constructor.h"
#include "pbd/string_convert.h" #include "pbd/string_convert.h"
@ -732,5 +734,5 @@ Gtkmm2ext::set_source_rgb_a (cairo_t *cr, Color color, float alpha)
Color Color
Gtkmm2ext::random_color () Gtkmm2ext::random_color ()
{ {
return ((random() % 16777215) << 8 | 0xff); return ((g_random_int() % 16777215) << 8 | 0xff);
} }