title: VisualC++ referencing C functions from C++
body: <p>I am trying to use a <a href="https://sourceforge.net/projects/oncrpc-windows/" rel="nofollow noreferrer">ONCRCP-Windows port</a> from a C++ application but I have some problem referencing function within the library.
  In the library there is a C file which contains the following C function definition:</p>
  
  <pre><code>//xdr_stdi.c
  ….
  void
  xdrstdio_create(xdrs, file, op)
      register XDR *xdrs;
      FILE *file;
      enum xdr_op op;
  {
  
      xdrs-&gt;x_op = op;
      xdrs-&gt;x_ops = &amp;xdrstdio_ops;
      xdrs-&gt;x_private = (caddr_t)file;
      xdrs-&gt;x_handy = 0;
      xdrs-&gt;x_base = 0;
  }
  </code></pre>
  
  <p>A declaration of the same function is present in a header file as follow:</p>
  
  <pre><code>// xdr.h
  DllExport void   xdrstdio_create(); /* XDR using stdio library */
  </code></pre>
  
  <p>If I call this function from a <code>main.c</code> file this works correctly but If I call this from a <code>main.cpp</code> it complains saying:</p>
  
  <pre><code>“error C2660: 'xdrstdio_create': function does not take 3 arguments”
  </code></pre>
  
  <p>This actually makes sense to me and I am honestly surprised that in C this does not complain… I however tried to include the header file wrapping the <code>#include</code> in an <code>extern C{ #include... }</code> but this did not help.
  Strangely enough replacing the definition in the header by</p>
  
  <pre><code>DllExport void   xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op);
  </code></pre>
  
  <p>Makes the library do not compile with error error </p>
  
  <pre><code>C2143: syntax error: missing ')' before '*'
  </code></pre>
  
  <p>I did not spend time tracking this second issue down... i would rather understand why the first case does work fine in C but not in C++</p>