title: Is there a way to get the filename from a `FILE*`?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1188757/getting-filename-from-file-descriptor-in-c">Getting Filename from file descriptor in C</a>  </p>
  </blockquote>
  
  
  
  <p>Is there a simple and (reasonably) portable way of getting the filename from a <code>FILE*</code>?</p>
  
  <p>I open a file using <code>f = fopen(filename, ...)</code> and then pass down <code>f</code> to various other functions, some of which may report an error.  I'd like to report the filename in the error message but avoid having to pass around the extra parameter.</p>
  
  <p>I could create a custom wrapper <code>struct { FILE *f, const char *name }</code>, but is there perhaps a simpler way?  (If the <code>FILE*</code> wasn't opened using <code>fopen</code> I don't care about the result.)</p>