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, VARIANT
let's me do everything, but I cannot resort to it under OS X (or even under linux).
Just as comment, up to now, I can do things like these for (involving "simple" types) :
I have the following code configuration : in tmp3class.h :
class TheClass
{
public:
double mysum(double x ,double y);
};
in tmp3class.cpp :
#include "./tmp3class.h"
double TheClass::mysum(double x ,double y)
{
return x+y ;
}
and in tmp3.cpp :
#include "./tmp3class.h"
extern "C"
{
double THESUM(double x, double y)
{
TheClass TheObj ;
double res = TheObj.mysum(x,y);
return res ;
}
}
I compile this with :
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
and then in the vba I do this :
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
and the function THESUM_VBA
works perfectly well.