title: Use of resolv.h
body: <p>I'm trying to find out my DNS server address by reading it from resolv.h's _res struct. According to man 3 resolver the setup code should be.</p>
  
  <pre><code>#include &lt;netinet/in.h&gt;
  #include &lt;arpa/nameser.h&gt;
  #include &lt;resolv.h&gt;
  
  extern struct state _res;
  </code></pre>
  
  <p>and then I just read out whatever I need. My problem is that trying to compile this I get</p>
  
  <pre><code>resolver.c:5:21: error: conflicting types for '__res_state'
  extern struct state _res;
                      ^
  /usr/include/resolv.h:251:16: note: expanded from macro '_res'
  #define _res (*__res_state())
                 ^
  /usr/include/resolv.h:249:28: note: previous declaration is here
  extern struct __res_state *__res_state(void) __attribute__ ((__const__));
                             ^
  1 error generated.
  </code></pre>
  
  <p>by clang.</p>
  
  <p>What am I doing wrong?</p>