Junling
Junling

Reputation: 37

rand_r():Identifier is undefined , vs2008

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

Answers (2)

Sebastian Mach
Sebastian Mach

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.


man 3 rand_r

Upvotes: 3

Some programmer dude
Some programmer dude

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

Related Questions