title: Include .c files in Unit test project and get access to it from multiple cpp files without linking problems
body: <p>I'm doing functional testing on c code. Have include .c file in test .cpp file so far, everything works well. But I need to include the same .c file in another .cpp file where I do other unit tests. Then I get problems that is already defined. Because I already include it in the first file cpp.</p>
  
  <p>If merge all the test methods into one cpp file then it works well. If keep all unit test in one file get to big handle so I need to split up diffrent files in same project it also create help functions for secure that functions get in capsules.</p>
  
  <p>This not a normal LNK2005 because I can not declare the variable and functions in .h: as extern BOOL MyBool; and then assign to it in a .c or .cpp file. Because need include c file as I do unit test this function. Also I can't or should avoid do any changes .c.</p>
  
  <p>I looking way to keep include of .c local not effect other files in same project.</p>
  
  <p>source.h</p>
  
  <pre><code>#ifndef SOURCE_H_
  #define SOURCE_H_
  
  #include "../car.h"
  
  enum INITIALMODE {
     INITIALMODE_NOT_POSITIONING,             // 0
     INITIALMODE_NO_DRIVER_INPUT,             // 1
     INITIALMODE_POSITION_LOW_POSITION,       // 2
     INITIALMODE_POSITION_STANDARD_POSITION,  // 3
     INITIALMODE_POSITION_HIGH_POSITION       // 4
  };
  void initMotor(void);
  #endif
  </code></pre>
  
  <p>source.c</p>
  
  <pre><code>/* Compiler include files */
  #pragma once
  
  #include "positioning.h"
  #include "api.h"
  #include "drive.h"
  #include "types.h"
  
  static void updateTarget(void);
  static SWord getMax(UWord Limit, UWord Aux);
  static DWord getHeight(void);
  static Bool isMode(void);
  static Bool isExiting(void);
  
  #define cMaxHeight      100 * Profile.s.Max /* m -&gt; mm */
  
  void initMotor(void)
  {
     // do something
  }
  
  static void updatePositioning(void)
  {
     // do something
  }
  </code></pre>
  
  <p>Test files look like this, however, this is very scaled for making exemple small.</p>
  
  <p><strong>UnitTest.cpp</strong> and <strong>UnitTest2.cpp</strong></p>
  
  <pre><code>#include "CppUnitTest.h"
  
  #ifndef UNIT_TEST
  #define UNIT_TEST
  
  using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  
  namespace Test
  {
  
      extern "C" {
       #include "../../Test/source.h"
       #include "../../Test/source.c"
      }
  
  TEST_CLASS(UnitTest_1)
  {
  public:
  
      TEST_METHOD(Test_1)
      {
          // Verify that the initial state is as expected.
          initTest();
  
          //Expected value
          UWord Expected = 500
          //Trigger to execute.
          UWord Test = updatePositioning();
  
          // Verify that the results are as expected.
          Assert::AreEqual(Expected, Test);
  
        }
     };
  }
  #endif
  </code></pre>