[CLN-list] CLN with MinGW compiler

Richard B. Kreckel kreckel at ginac.de
Tue Apr 5 23:10:03 CEST 2005


On Tue, 5 Apr 2005, zkoza wrote:
> I have tried to compile CLN (with GiNaC as my eventual target)
> using MinGW compiler under Windows.
> This compiler uses GNU gcc compiler (3.4) and allows one to compile native
> Windows GUI programs.
> However, neither CLN 1.1.9 nor 1.1.6 does not compile under MinGW.
> The reason seem to be in file cl_random_from.cc, which attempts to
> declare a function get_seed and use it to set the lower bits of a random
> number seed.
> Now, Mingw does not seem to have gettimeofday nor times, hence
> it "forgets" to declare get_seed, even though the compiler is a GNU compiler;
> consquently the compilation ends with an error.
>
> I "patched" the code as follows:
>
> // old code
> #elif defined(HAVE_TIMES_CLOCK)
>
> #include <ctime>
> #ifndef CLK_TCK
> #include <sys/time.h>
> #endif
> #include <sys/times.h>
> extern "C" clock_t times (struct tms * buffer);
>
> inline uint32 get_seed (void)
> {
> 	var struct tms tmsbuf;
> 	var uint32 seed_lo = times(&tmsbuf);
> 	return seed_lo + tmsbuf.tms_utime + tmsbuf.tms_stime;
> }
> // NEW CODE STARTS HERE
> #else                          // NEW CODE
> #include <time.h>              // NEW CODE
> inline uint32 get_seed (void)  // NEW CODE
> {                              // NEW CODE
> 	return time(0);            // NEW CODE
> }                              // NEW CODE
>
>
> Apparently this makes the library compile.
> Do you think such a "patch" is reasonable?

Looking at src/base/random/cl_random_from.cc I wonder whether it wouldn't
be possible to use the defined(__MSDOS__) branch inside the ctor
random_state::random_state().  Doesn't get_real_time() work on your
system?  (BTW: The comment there says "No random numbers, no PID, nothing
random whatsoever".)

Regards
  -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>





More information about the CLN-list mailing list