title: Variable already defined in .obj, but no circular includes
body: <p>I know, there are a lot of similar problems and solutions already on SO, and I read them, but none of them helped me solve my problem.</p>
  
  <p>I created a class for logging. 
  Here is <code>Logger.h</code></p>
  
  <pre><code>#ifndef LOGGER_H
  #define LOGGER_H
  
  namespace Logger
  {
  namespace debug
  {
  
      int Error = 0, OtherNumber;
  
      class log
      {
      public:     // Methods
          void Save();
  
      private:    // Members
          static int indentation;
          const std::wstring context;
          int Type, LineNumber;
  
      public:     // Constructor, Destructor
          log( const std::wstring&amp; context, int LineNumber, int Type );
          ~log();
  
      };//class log
  
  }//namespace debug
  
  }//namespace Logger
  
  #endif //LOGGER_H
  </code></pre>
  
  <p><code>Logger.cpp</code></p>
  
  <pre><code>#include "stdafx.h"
  
  #include "Logger.h"
  
  namespace Logger
  {
  namespace debug
  {
      log::log( const std::wstring&amp; ctx, int linenr, int type ): context( ctx ), LineNumber( linenr ), Type( type )
      {
          printf("\nLogging start! Context = %ls - Line = %d - Type = %d", context.c_str(), LineNumber, Type );
      }
  
      log::~log()
      {
          printf( "\nLogging end! Context = %ls - Line = %d - Type = %d", context.c_str(), LineNumber, Type );
          printf( "\nUsing Error here =%d", Error );
      }
      void log::Save()
      {
          FILE *fp = NULL;
  
          fclose( fp );
          fp = fopen( "mylogfile.log", "a" );
      }
  
  }//namespace debug
  
  }//namespace Logger
  </code></pre>
  
  <p>Then in <code>main.h</code> I have:</p>
  
  <pre><code>#ifndef MYAPP_H
  #define MYAPP_H
  
  #include "Logger.h"
  
  #define WIDEN2( x )     L ## x
  #define WIDEN( x )      WIDEN2( x )
  #define WFILE       WIDEN( __FILE__ )
  
  #define __STR2WSTR( str )   L##str
  #define _STR2WSTR(str)  __STR2WSTR(str)
  #define WFUNCTION       _STR2WSTR( __FUNCTION__ )
  
  #define DEBUGLOG_START( Type )  Logger::debug::log _debugLog( WFUNCTION, __LINE__, Type );
  #define DEBUGLOG_SAVE   { _debugLog.Save(); }
  
  #endif //MYAPP_H
  </code></pre>
  
  <p>And finally in <code>main.cpp</code> I have:</p>
  
  <pre><code>#include "Test_UserPart.h"
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  
  DEBUGLOG_START( 1 )
  
  Logger::debug::OtherNumber = 10;
  
  _getch();
  return 0;
  }
  </code></pre>
  
  <p>When I want to compile it I get the error <code>error LNK2005: "int Logger::debug::Error" (?Error@debug@Logger@@3HA) already defined in Logger.obj ...MyApp.obj</code></p>
  
  <p>So as far as I see, I didn't make any circular includes. But why do I get this error?</p>
  
  <p>Thanks!</p>