'random':找不到标识符错误
'random' : identifier not found error
我正试图将为UNIX编写的代码移植到Visual studio,但收到以下错误
random.cpp(29): error C3861: 'initstate': identifier not found
random.cpp(37): error C3861: 'random': identifier not found
random.cpp(49): error C3861: 'random': identifier not found
random.cpp(51): error C3861: 'random': identifier not found
random.cpp(63): error C3861: 'random': identifier not found
random.cpp(78): error C3861: 'SQRT': identifier not found
random.cpp(78): error C3861: 'LOG': identifier not found
random.cpp(78): error C3861: 'COS': identifier not found
random.cpp(87): error C3861: 'ABS': identifier not found
代码很长,但我已经包含了math.h,但我仍然会遇到这些错误。这些函数可能只是UNIX!如果是,我有什么选择?
这是我的代码的一个修改过的示例(给我带来错误的行);
if( NULL == initstate(2, rngState, 256) )
do something...
int r = (int)( (rangeEnd - rangeStart) * random() );
double z = SQRT(-2.0 * LOG(x1)) * COS(2.0 * M_PI * x2);
SQRT
->sqrt
LOG
->log
COS
->cos
random
->rand
(别忘了# include <stdlib.h>
)
并在main之前写入initstate
或进行正向声明。
包括stdlib.h并使用函数rand()。
此外,函数的名称使用小写cos、log、sqrt。
相关文章:
- 设置 Visual Studio for MPI: 找不到标识符错误
- 错误 C2760:语法错误:映射迭代器上意外的标记"标识符",预期的";"
- C++:枚举:错误:应使用标识符而不是"}"
- 我的代码中有错误,未声明的标识符
- 错误:在 C++ 'std'使用未声明的标识符
- 从子类访问模板类成员时出现"找不到标识符"错误
- 为什么更改包含 psapi.h 的顺序会产生编译错误?(标识符 BOOL 未定义)
- 未声明的标识符错误,但变量定义正确 (?)
- C++ 多态构造函数错误;标识符未定义
- 虚幻引擎4:UShape组件给出错误"标识符未定义"。我能做什么?
- 如何修复可视化工作室中的"C2061语法错误标识符"堆栈?
- C++结构错误 - 错误 C2061:语法错误:标识符
- 在给定的代码中获取错误(标识符未定义)
- 视觉 在调用它时用 c++ 创建一个方法后,我得到的错误标识符未找到
- C++Visual Studio类错误标识符字符串未定义
- C++错误C2061:语法错误:标识符
- 智能感知错误标识符"emlrtStack"未定义
- 错误:标识符未在c++中定义
- Visual Studio错误:语法错误:标识符
- 错误 C2061:语法错误:标识符,但已包含头文件