srand48() : Unable to compile due to scope issues on Windows in Dev-C++.

981 views
Skip to first unread message

ajiten

unread,
Mar 24, 2019, 12:43:39 AM3/24/19
to ISO C++ Standard - Discussion
Dev-C++ version 5.5.2 (Windows 7) gives compilation error that occurs in the last line in main():

[Error] 'srand48' was not declared in this scope

#include <sys/time.h>
#include <cmath>
#include <cstdlib>
#include <stdlib.h>

extern double drand48();
extern long lrand48(/*long*/);
extern int rand();
extern void srand(long seedval);



//main program
main()
{

//set random number generator
struct timeval tp;
struct timezone tzp;
gettimeofday(&tp,&tzp);
srand48(tp.tv_usec); //compilation error occurs here: [Error] 'srand48' was not declared in this scope
}    


peter...@gmail.com

unread,
Mar 24, 2019, 6:30:52 AM3/24/19
to ISO C++ Standard - Discussion
srand48 is not a standard C++ function.
Reply all
Reply to author
Forward
0 new messages