title: passing c/c++ dylib function taking pointer to VBA on mac
body: <p>I am actually playing with interfacing c/c++ and the VBA of Excel-2011 for mac. How could I design, in the dylib, functions taking pointers as parameters, or references ? Or arrays ? Or even simple structs ? Under windows, <code>VARIANT</code> let's me do everything, but I cannot resort to it under OS X (or even under linux).</p>
  
  <p>Just as comment, up to now, I can do things like these for (involving "simple" types) :</p>
  
  <p>I have the following code configuration : in tmp3class.h :</p>
  
  <pre><code>class TheClass
  {
        public:
              double mysum(double x ,double y);
  };
  </code></pre>
  
  <p>in tmp3class.cpp :</p>
  
  <pre><code>#include "./tmp3class.h"
  
  double TheClass::mysum(double x ,double y)
  {
        return x+y ;
  }
  </code></pre>
  
  <p>and in tmp3.cpp :</p>
  
  <pre><code>#include "./tmp3class.h"
  
  extern "C"
  {
        double THESUM(double x, double y)
        {
              TheClass TheObj ;
              double res = TheObj.mysum(x,y);
              return res ;
        }
  }
  </code></pre>
  
  <p>I compile this with :</p>
  
  <pre><code>g++-5.2.0 -m32 -Wall -g -c ./tmp3class.cpp -o ./tmp3obj.o
  g++-5.2.0 -m32 -dynamiclib .tmp3.cpp ./tmp3obj.o -o ./tmp3.dylib
  </code></pre>
  
  <p>and then in the vba I do this :</p>
  
  <pre><code>Declare Function THESUM Lib "/Users/XXXXXX/Documents/GITHUBRepos/DYLIBS/MyFirstDylib/tmp3.dylib" (ByVal x As Double, ByVal y As Double) As Double
  
  Function THESUM_VBA(x As Double, y As Double) As Double
      THESUM_VBA = THESUM(x, y)
  End Function
  </code></pre>
  
  <p>and the function <code>THESUM_VBA</code> works perfectly well.</p>