arc4random is undefined in Visual Studio 2010 Ultimate

I’m a really beginner in Cocos2d x. I follow this tutorial: http://www.raywenderlich.com/33752/cocos2d-x-tutorial-for-ios-and-android-space-game. arc4random was introduce to use but Visual Studio always display Error identifier “arc4random” is undefined. I done some searching and I found that arc4random is method for using in iPhone. I’m developing using Windows 7 with VS 2010 ultimate. My question is: is it possible to use arc4random in Windows or it’s a bad idea to develop app using Cocos2d x in Windows? Please help.

Hi Khath,

You can use rand with VS 2010. You can also use srand.

Regards

I already tried both but it just I need to use arc4random. It’s strange because when I compile it with Android ADT there is no error inform. Thank you so much for your reply :slight_smile: I’m glad you reply my post.

Was this issue resolved? I am also having similar problem.

It all depends on the compiler and stdlib you’re building against.

This is not an “issue” with Cocos2d-x this is the reality of C++

corytrese is right.

You can include stdlib.h and use its rand() instead.

Hope this helps.