I can't seem to find void random() (with no arguments) defined in the library and yet my sketches seem to compile just fine when calling random() with no arguments.

I've found random with 1 argument and random with 2 arguments but no cases of random with no arguments.

Is random() defined in the library with no arguments?

If so, where is it defined?

If it isn't, what could explain how my code compiles despite me not providing any arguments?

  • 1
    It's defined in stdlib.h Nov 8 '17 at 18:32
  • @sempaiscuba Sadly Ignacio got there 8 minutes sooner, but that is indeed correct.
    – Pharap
    Nov 8 '17 at 18:34
  • 1
    Sorry about that. The question came up in review, so I added the comment rather than an answer. :) Nov 8 '17 at 18:52

It's defined in the libc, in stdlib.h.

  • That explains why I couldn't find it in the Arduino github's source code.
    – Pharap
    Nov 8 '17 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.