Reputation: 37
when i use rand_r() in vs2008, it comes to 1 error--Identifier is undefined, can i use rand() instead ? (multithread programming work.) thanks.
Upvotes: 0
Views: 5767
Reputation: 39099
You'd have to
#include <cstdlib>
In case you need this for multithreading purposes, see also Joachim Pileborgs answer.
In any case, maybe use one of C++'s new RNGs, which you use in form of objects and that have guaranteed sequences.
Upvotes: 3
Reputation: 409196
According to this forum thread you should be able to use rand
without needing to worry about reentrancy when using VC++.
Upvotes: 1