title: Implicit Declaration of Function ‘strtok_r’ Despite Including <string.h>
body: <p>I have the following code to tokenize a string containing lines separated by <code>\n</code> and each line has integers separated by a <code>\t</code>:</p>
  
  <pre><code>void string_to_int_array(char file_contents[BUFFER_SIZE &lt;&lt; 5], int array[200][51]) {
    char *saveptr1, *saveptr2;
    char *str1, *str2;
    char delimiter1[2] = "\n";
    char delimiter2[2] = " ";
    char line[200];
    char integer[200];
    int j;
    for(j = 1, str1 = file_contents; ; j++, str1 = NULL) {
      line = strtok_r(str1, delimiter1, &amp;saveptr1);
  
      if (line == NULL) {
        break;
      }
  
  
      for (str2 = line; ; str2 = NULL) {
        integer = strtok_r(str2, delimiter2, &amp;saveptr2);
        if (integer == NULL) {
          break;
        }
      }
    }
  }
  </code></pre>
  
  <p>(Have included only the relevant function here, the complete, if required, is <a href="http://pastebin.ubuntu.com/7553221/" rel="noreferrer">here</a>.)</p>
  
  <p>However, when I try to compile this code using:</p>
  
  <pre><code>gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes file_read.c
  </code></pre>
  
  <p>I get the following warnings:</p>
  
  <pre><code>file_read.c:49:5: warning: implicit declaration of function ‘strtok_r’ [-Wimplicit-function-declaration]
       line = strtok_r(str1, delimiter1, &amp;saveptr1);
       ^
  file_read.c:49:10: error: incompatible types when assigning to type ‘char[200]’ from type ‘int’
       line = strtok_r(str1, delimiter1, &amp;saveptr1);
            ^
  file_read.c:59:15: error: incompatible types when assigning to type ‘char[200]’ from type ‘int’
         integer = strtok_r(str2, delimiter2, &amp;saveptr2);
                 ^
  </code></pre>
  
  <p>Line nos 49 and 59 correspond to the <code>strtok_r</code> call.</p>
  
  <p>As you can see, I have included <code>string.h</code> in my file (which is where <code>strtok_r</code> is declared), still I get the implicit declaration warning for <code>strtok_r</code>.</p>
  
  <p>Any insights as to how I can remove the warning is appreciated.</p>
  
  <p>I am using gcc 4.8.2 on ubuntu 14.04 64-bit desktop.</p>