include header file error: multiple definition
<p>I have a very simple file system in a program.</p>

<p>There is :main.cpp which include worker.h, worker.h and worker.cpp which include worker.h</p>

<p>worker.h has the Header guard and has some variables declared which are required by both main.cpp and worker.cpp and it has some function declarations.</p>

<pre><code>#ifndef __WORKER_H_INCLUDED__
#define __WORKER_H_INCLUDED__

    bool x;
    int y;

    void somefunction( int w, int e );

#endif
</code></pre>

<p>Going through some other threads and google results, I understood that the Header guard protects you from multiple inclusions in a single source file, not from multiple source files.</p>

<p>So I can expect linker errors.</p>

<p>My question is </p>

<ol>
<li><p>Why there are multiple definition errors for only variables and not for functions ? As far as my understanding goes both of those are only declared and not defined in the header file worker.h</p></li>
<li><p>How can I make the a variable available to both main.cpp and worker.cpp without the multiple definition linker error ?</p></li>
</ol>
