c++ - rand_r() :Identifier is undefined , vs2008

标签 c++ linux thread-safety

当我在 vs2008 中使用 rand_r() 时,出现 1 个错误--Identifier is undefined,我可以改用 rand() 吗? (多线程编程工作。) 谢谢。

最佳答案

你必须

#include <cstdlib>

如果您出于多线程目的需要它,另请参阅 Joachim Pileborgs 的回答。

无论如何,可以使用 C++'s new RNGs 之一,您以对象的形式使用它并且具有保证的顺序。


man 3 rand_r

关于c++ - rand_r() :Identifier is undefined , vs2008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9615678/

相关文章:

mysql - 配置单元使用 mysql 元存储

linux - 匹配多列并打印二进制结果

当应用程序使用 poll() 而不是 linux 中的 epoll() 时,调用被路由到驱动程序

java - 防止在多线程上下文中使用非线程安全方法

c++ - 将用户名和密码发送到 Web 服务器的 HTTP 命令是什么?

c++ - 堆与堆栈上 protected 析构函数对象分配

.net - .Net 的 LinkedList 实现是线程安全的吗?

java - Java LongAdder的increment()和sum()是否会阻止两次获得相同的值?

c++ - 模板 - 必要时使用 int、short 或 float 的类

c++ - Stencil Buffer 有什么用?