title: open() system call header file requirements
body: <p>I am using x86_64 GNU/Linux with gcc.<br>
  SYNOPSIS section of <code>man -s2 open</code> says:  </p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  
  int open(const char *pathname, int flags);
  int open(const char *pathname, int flags, mode_t mode);
  int creat(const char *pathname, mode_t mode);
  </code></pre>
  
  <p>Now when I try to compile the following code snippet, <code>gcc</code> doesn't throw a warning/error.  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;fcntl.h&gt;
  
  int main(int argc, char **argv)
  {
      int fd;
  
      fd = open("foo.txt", O_RDWR, 0777);
      if(fd == -1)
          perror("open");
  
      fd = creat("foo.txt", 0777);
      if(fd == -1)
          perror("creat");
  
      close(fd);
      return 0;
  }
  </code></pre>
  
  <p>So are <code>types.h</code> and <code>stat.h</code> optional? What purpose do they serve in manpage of <code>open()</code>?</p>