<p>I am a bit confused why this code compiles.  I leave out the "necessary" <code>#include &lt;OpenGL/gl.h&gt;</code> and still the program can compile.  How is this possible when my program is calling functions from the GL library, without including them.</p>

<pre><code>int main(int argc, char** argv)
{

    glClearColor(1.0,1.0,1.0,1.0);
    return 0;
}
</code></pre>

<p>I use this compilation command:</p>

<pre><code> gcc -framework GLUT -framework OpenGL test.c
</code></pre>

<p>I was under the assumption that adding -framework just specifies to the linker where the library is, but I thought I still need the headers?</p>

glClearColor isn't a macro so you don't
need
the headers to define it. If you add warnings:
```
```
gcc -o test -Wall -W test.c -framework GLUT -framework OpenGL
```
```
Then you'll get a warning about the implicit declaration of glClearColor. You also won't be able to use any macros as the compiler will give you an error that they are undefined. Since the glClearColor symbol gets properly resolved by the linker, you never get an error.
It also occurs to me that you might have been wondering this because you thought you were compiling for C++. The example you gave actually compiles C code where it is not an error to fail to declare function prototypes. If you meant to compile this as C++ code, you would need the following command line:
g++ -o test test.cpp -framework OpenGL
In that case you most certainly would get an error for not including gl.h and your code would fail to compile. When executing GCC from the command line, g++ is the C++ compiler while gcc is the general C compiler.