Forums > Dev

Where does the random() function from SDK's urner example come from ?

March 31, 2013 | 6:36 pm

Hello,

Random number generation examples in c most often include the C ANSI rand() and srand() functions. Some people use more sophisticated solutions (see this thread for instance) but those demand external libraries or much complex code. Therefore I do not understand where the random() function used in the SDK’s urner example come from. I can’t see it neither in ext.h nor in ext_obex.h. Is it Darwin-specific stuff ? Why isn’t there any inclusion of a specific header file to use it ?

Thank you in advance.


April 1, 2013 | 8:43 am

Thanks Nicolas.

In between I have used the ANSI rand function.

It’s strange that there’s no #include line in the SDK’s urner example. Even stranger: I have also forgotten to include stdlib.h (for rand) and time.h (to seed srand) in my code and it compiled flawlessly. Also the object functions as expected. So I suppose there is a kind of explicit inclusion of these functions. Is the whole C standard library included in such an implicit way ?


April 1, 2013 | 2:43 pm

Thanks again Nicolas !


Viewing 3 posts - 1 through 3 (of 3 total)