[CLN-list] CLN with MinGW compiler

zkoza zkoza at ift.uni.wroc.pl
Tue Apr 5 17:38:13 CEST 2005


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?


Z. Koza




More information about the CLN-list mailing list