title: Why doesn't getrandom() compile?
body: <p>Silly question, I'm probably missing a header, but the man page says I just need <code>#include &lt;linux/random.h&gt;</code>.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;linux/random.h&gt;
  
  #define BITS 8192
  #define BYTES (BITS &gt;&gt; 3)
  
  int main() {
      uint8_t array[BYTES];
  
      printf("started...");
      int r = getrandom(array, BYTES, 0);
      if (r) exit(1);
  
      return 0;
  }
  </code></pre>
  
  <p>Error is:</p>
  
  <pre><code>chris@purple:~/lunch/bitarray$ make &amp;&amp; ./bitarray 
  clang -g -Wall -Wpedantic -Werror -std=c11 -O2 -save-temps bitarray.c -o bitarray
  bitarray.c:13:10: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   int r = getrandom(array, (8192 &gt;&gt; 3), 0);
           ^
  1 error generated.
  Makefile:10: recipe for target 'bitarray' failed
  make: *** [bitarray] Error 1
  </code></pre>
  
  <p>(Also fails in gcc.)</p>
  
  <pre><code>chris@purple:~/lunch/bitarray$ cat /etc/lsb-release 
  DISTRIB_ID=Ubuntu
  DISTRIB_RELEASE=16.04
  DISTRIB_CODENAME=xenial
  DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
  chris@purple:~/lunch/bitarray$ uname -a
  Linux purple 4.4.0-83-generic #106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>