title: c++ compiler error "was not declared in this scope"
body: <p>I'm getting a bizarre compiler error when trying to compile a c++ UDP client program.</p>
  <blockquote>
  <p>g++ -o client Udp.cpp ClientMain.c -I. -lpthread</p>
  <p>In file included from ClientMain.c:1:0:</p>
  <p>Udp.h: In destructor ‘CUdpMsg::~CUdpMsg()’:</p>
  <p>Udp.h:103:43: error: ‘free’ was not declared in this scope</p>
  <p>Udp.h: In member function ‘void CUdpMsg::Add(in_addr_t, const void*, size_t)’:</p>
  <p>Udp.h:109:34: error: ‘malloc’ was not declared in this scope</p>
  <p>Udp.h:109:41: error: ‘memcpy’ was not declared in this scope</p>
  <p>ClientMain.c: In function ‘int main(int, char**)’:</p>
  <p>ClientMain.c:28:57: error: ‘memcpy’ was not declared in this scope</p>
  <p>ClientMain.c:29:61: error: ‘printf’ was not declared in this scope</p>
  <p>ClientMain.c:30:17: error: ‘stdout’ was not declared in this scope</p>
  <p>ClientMain.c:30:23: error: ‘fflush’ was not declared in this scope</p>
  <p>ClientMain.c:34:68: error: ‘printf’ was not declared in this scope</p>
  <p>ClientMain.c:35:17: error: ‘stdout’ was not declared in this scope</p>
  <p>ClientMain.c:35:23: error: ‘fflush’ was not declared in this scope</p>
  <p>ClientMain.c:37:30: error: ‘usleep’ was not declared in this scope</p>
  </blockquote>
  <p>I have the following declared at the beginning of my cpp file.</p>
  <pre><code>#include &lt;netinet/in.h&gt;
  #include &lt;netdb.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;arpa/inet.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;ifaddrs.h&gt;
  #include &lt;net/if.h&gt;
  #include &lt;cstdlib&gt; 
  #include &lt;string&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;cstring&gt;
  
  #include &lt;errno.h&gt;
  </code></pre>
  <p>functions like 'memcpy' should be declared in string.h... I have it (and string and cstring) all declared, and I'm still getting these compiler errors. Does anyone have a clue why this is happening? Thanks.</p>