title: Error "'fdopen' was not declared" found with g++ 4 that compiled with g++3
body: <p>I have code that compiled happily with g++ version 3.something. I then wanted to build some other code that had C++11 symbols in it so I upgraded to g++ 4.7. Now my original code doesn't build. I get the error:</p>
  
  <p>'fdopen' was not declared in this scope</p>
  
  <p>According to the man page, fdopen() is declared in stdio.h which I am including. I'm not sure it is relevant, but I am working in a Cygwin environment. The exact version of g++ I am using is version 4.7.2 provided by Cygwin.</p>
  
  <p>I have not changed this code since I switched compiler and I can definitely confirm that it built and my test code ran and passed with the previous compiler.</p>
  
  <p>As requested, example code to demonstrate the problem:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  
  int main(int argc, char **argv)
  {
      int   fd;
      FILE *fp;
  
      fd = open("test.txt", (O_WRONLY | O_CREAT | O_EXCL), S_IRWXU);
      if(0 &lt; fd)
      {
          fp = fdopen(fd, "wb");
  
          fprintf(fp, "Testing...\n");
          fclose(fp);
      }
  
      return 0;
  }
  
  
  # g++ -std=c++11 -o test test.cpp
  test.cpp: In function 'int main(int, char**)':
  test.cpp:14:29: error: 'fdopen' was not declared in this scope
  </code></pre>