Arc4Random replacement in Windows Phone for project created for iOS

Arc4Random replacement in Windows Phone for project created for iOS
0.0 0



our project was creating using cocos2d on Mac to create iPhone app first. Now we would like to port it to Windows Phone. We have use Arc4Random in our iOS project that we cannot find in VC++ for windows phone. Am I missing a reference to do I need to use a different function for the same?

Thank you in advance.


should work if you add

#include <math.h>

probably just how you typed it but should be arc4random()

e.g. float value = arc4random() % 100;


Thank you so much for your response.

I tried including <math.h> with no luck. I noticed that in Cocos2d project in xCode arc4random is part of stdlib.h. I tried including that as well, since I did not see it in the file. neither of them did not work. I am hoping to use rand() to resolve this. if there is further solution, I can look into it as well.

Thank you again!


Here is a nice blog post showing one possible way to work around the fact that arc4random() is only included in some C*+ stdlibs.

I’m using something similar because we’re compiling to so many different C*+ stdlibs.



This looks like a great solution. I have to try it yet. In the mean time we are using rand() instead. I do not know the difference between them. i guess one is more performant than other. As of now it is working as expected. We will update here if we find anything different.

Thank you so much.