title: swig -c++ option breaks wrapper of pure C files with error C3861:unresolved externals
body: <p>I am trying to wrap a C API I was given so it can be use in Python using SWIG. This API requires call back functions be passed to it from Python (Python passing a Python function to C which is called from C and executed in Python). This is doable using C++ and directors - <code>%module(directors=&quot;1&quot;)</code>. However when I add the <code>-c++</code> option to the swig set-up file it fails to find any of the C functions in the linking stage. It compiles fine and will run in Python, less the needed callbacks, before I add the <code>-c++</code> option.</p>
  <p>I have created a very simple example of this form the demo code:</p>
  <p>add.c:</p>
  <pre><code>#include &lt;stdio.h&gt;
  int add_func(int x, int y) {
      return x+y;
  }
  </code></pre>
  <p>add.h:</p>
  <pre><code>int add_func(int x, int y);
  </code></pre>
  <p>add.i:</p>
  <pre><code>%module add
  %{
      #include &quot;add.h&quot;
  %}
  %include &quot;add.h&quot;
  </code></pre>
  <p>setup.py:</p>
  <pre><code>from setuptools import setup, Extension
  
  setup(
      name='add',
      py_modules=['add'],
      ext_modules=[
          Extension('_add',
                    sources=['add.c', 'add.i'],
                    swig_opts=['-c++']
          )
      ]
  )
  </code></pre>
  <p>compile command:</p>
  <pre><code>python3 setup.py build_ext --inplace
  </code></pre>
  <p>with <code>swig_ops=['-c++']</code> I get the following error:</p>
  <pre><code>add_wrap.obj : error LNK2001: unresolved external symbol &quot;int __cdecl add_func(int,int)&quot; (?add_func@@YAHHH@Z)
  build\lib.win32-3.8\_add.cp38-win32.pyd : fatal error LNK1120: 1 unresolved externals
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\link.exe' failed with exit status 1120
  </code></pre>
  <p>with <code>swig_ops=['-c++']</code> removed it compiles fine.</p>
  <p>So the question is can you use pure C code with C++ and swig? If so how?</p>
  <p>System info:</p>
  <blockquote>
  <pre><code>SWIG Version 4.0.2
  Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 &gt; 32 bit (Intel)] on win32 exe
  </code></pre>
  </blockquote>