Are header files not compiled (C++ Visual Studio 2015)
<p>Just to see if it would work (I know it's awful form), I fully defined a function in a header file and made a corresponding forward declaration for said function in the main cpp file. C++ functions don't need to be defined in the translation unit they're used in, hence why header files are almost entirely just forward declarations (with the exception of inline functions). However, when I tried to compile this project, it said that there were unresolved externals.</p>

<p>When I moved the entire contents of the header file into a source file (removing the header file as well), it compiled just fine and executed as expected. So, are header files just not compiled when building a project, or is there just some exception I don't know about?</p>

<p>Additionally, even when I just go to the header file's properties in the property explorer and set its <code>File Type</code> to <code>C/C++ Code</code> and change its extension to .cpp, it still won't compile (even though it will if i just delete it and create a fresh source file, which I think is the oddest part).</p>

<p>(I'm working with extensions disabled <code>/Za</code>, if that changes anything)</p>

<p>Here's the code file</p>

<pre><code>//main.cpp
void foo();

void main()
{
    foo();
}
</code></pre>

<p>and the header file</p>

<pre><code>//test.h
#include &lt;iostream&gt;

void foo()
{
    std::cout &lt;&lt; 'a';
}
</code></pre>