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

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

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

    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


    Code:
    #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()
    {
    //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
    }
    Last edited by ajiten73; 03-24-2019 at 01:04 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class scope issues
    By chemicalhead in forum C++ Programming
    Replies: 3
    Last Post: 05-28-2013, 01:03 AM
  2. Replies: 0
    Last Post: 10-29-2011, 11:30 PM
  3. libusb: unable to compile
    By nndhawan in forum C Programming
    Replies: 1
    Last Post: 02-17-2011, 10:56 PM
  4. Dev-c++ + own .h files = unable to compile
    By wixz64 in forum C Programming
    Replies: 5
    Last Post: 05-29-2008, 03:35 PM
  5. c++ class scope issues
    By avatarofhope2 in forum C++ Programming
    Replies: 13
    Last Post: 10-23-2007, 07:20 PM

Tags for this Thread