A compile-time symbol was #defined but #ifdef does not see it
<p>I have a test class declared in a header file and defined in a separate file. The class must compile differently under Windows, so i use <code>#if defined ( _WINDOWS_ )</code>. When I compile the cpp file which also contains <code>#if defined ( _WINDOWS_ )</code>, the file is compiled as if the symbol <code>_WINDOWS_</code> was not defined, although it is defined in another file. When I compile the code, I am getting the following error:</p>

<blockquote>
  <p>Error Code : error lnk2019 unresolved external symbol public</p>
</blockquote>

<p>source code </p>

<pre><code>// test.h

class Test
{
public:
#if defined (_WINDOWS_)

void printwindow();
#endif

void notwindows();
}; 

//test.cpp

#include "test.h"

 #if defined (_WINDOWS_)
void Test::printwindow()
{
cout &lt;&lt; "i am windows ";
}
 #endif


void test::notwindows()
{
cout &lt;&lt; " not windows " ;
}


//main.cpp

#include "windows.h"
#include "test.h"

void main()
{
test t1 ; 

t1.printwindow()  // OK I have declared function so my _WINDOWS_ is available but when i run it i get
}
</code></pre>

<blockquote>
  <p>Error Code : error lnk2019 unresolved external symbol public</p>
</blockquote>

<p>NOTE : if i define the function directly it works without any problem </p>

<pre><code>// test.h

    class Test
    {
    public:
    #if defined (_WINDOWS_)

    void printwindow(){couT &lt;&lt; "i am window" }
    #endif

    void notwindows();
    };
</code></pre>

<p>but I don't like this method. I prefer to define them in separate files (h and cpp). </p>
