www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/05/19:55:26

From: "Chris Hut" <chut AT wesleyan DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: help w/ STL random_shuffle function (lrand48() undefined)
Date: Mon, 5 Apr 1999 19:19:55 -0400
Organization: Wesleyan University
Lines: 48
Message-ID: <7ebgcd$k3t@news.wesleyan.edu>
NNTP-Posting-Host: chut.stu.wesleyan.edu
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

This seems like a faq type thing, but I checked and haven't seen this
problem listed anywhere...

I'm working on a short program to simulate picks in a lotto (this is
straight out of "C++ Primer Plus," chapter 15, if it sounds familiar =).
The exercise is to use the STL, so I've designed a function that returns a
vector container.  To fill out the picks, I'm using a vector container
filled w/ the number of possible numbers (eg. {1, 2, 3, . . . 50}) in order,
then using random_shuffle on that vector, then copying the first three (for
a pick 3 game) into the vector that I return.  Everything's fine except for
the random_shuffle line:

#include <iostream>
#include <cstdlib>
#include <vector>
#include <iterator>
#include <algorithm>

vector<int> Lotto(int available, int selections)
{
    vector<int> card;
    . . . // a for loop to fill the vector linear-ly -- this works fine...
    // this line errors, function works fine when commented out:
    random_shuffle(card.begin(), card.end())
    . . . // rest of function
}

when compiling I get this error:
c:/djgpp/lang/cxx/stl_algo.h: In function 'void __random_shuffle<int *,
int>(int *, int *, int *)':
c:/djgpp/lang/cxx/stl_algo.h:617: 'lrand48' undeclared (first use this
function)
(stuff about each undeclared identifier only reported once)

So I checked out my \djgpp\lang\cxx\stl_algo.h file (which I've definitely
never modified), and found that random_shuffle() calls the function
__random_shuffle which definitely calls the function lrand48(), and a quick
text search indicates that it's nowhere to be found anywhere else in my
djgpp subdirectories.

If anyone can let me know what's going on here, I'd greatly appreciate it.
Also, if this problem is documented somewhere, just point me to where...

Thanks,
Chris


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019