title: With gcc, include strictly C99 symbols, specifically excluding POSIX
body: <p>I am taking a course in C after many years programming. My instructor is not using a POSIX machine, and I was recently penalized for using the <code>index</code> function in an assignment. I did some research and I notice that while <code>index</code> was an early part of AT&amp;T Unix and is POSIX-compliant, it is not part of the C99 standard. <em>I'd like gcc to help me find use of similar symbols</em>. I am compiling on OSX with gcc 4.2 (<em>not</em> llvm)</p>
  
  <p>My first leg of research involved noticing that my string.h file wraps the prototype for <code>index</code> in the following check for feature test macros:</p>
  
  <pre><code>#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
  </code></pre>
  
  <p>After a little digging, I found this (in my <code>/usr/include/sys/cdefs.h</code>):</p>
  
  <pre><code> /* STRICT  Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the
   *      available APIs to exactly the set of APIs defined by the
   *      corresponding standard, based on the value defined.
   *
   *      A correct, portable definition for _POSIX_C_SOURCE is 200112L.
   *      A correct, portable definition for _XOPEN_SOURCE is 600L.
   */
  </code></pre>
  
  <p>And so with this gcc command:</p>
  
  <pre><code>gcc -D _POSIX_C_SOURCE=200112L -pedantic -Wall -std=c99 -o myExec ./mySource.c
  </code></pre>
  
  <p>I <em>do</em> get a decent warning:</p>
  
  <pre><code>warning: incompatible implicit declaration of built-in function ‘index’
  </code></pre>
  
  <p>This confuses me, <em>and</em> I want to make the program fail to link as well. The reason it confuses me is, I read <a href="http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html" rel="noreferrer">at opengroup.org</a> that defining that macro should <strong>expose</strong> POSIX symbols, not hide them. So here is my question in a succinct form:</p>
  
  <p><strong>How can I make gcc 4.2 (on OSX 10.6) compile and link my program in an environment which is <em>strictly</em> C99 with <em>no additional symbols</em> available?</strong></p>
  
  <p>Ideally, I want <strong>warnings during compile and failure to link</strong>. I'm hoping that the answer does not involve telling gcc that I <em>am</em> writing POSIX code, when I believe that's the opposite of what I want to tell it. What am I not understanding?</p>