I simply want to pass a list of integers to a function written in C++. I've set up the template (.tm) file and all, and I can successfully call a test function whith scalar arguments. Calling the function with the list argument behaves as though the function was not defined at all. I suspect that the argument types don't match.
In the documentation for templates (http://reference.wolfram.com/mathematica/ref/file/file.tm.html) the datatype for lists is something like "Int32List". When I use that, my C++ function must contain an extra long parameter for the list length. The only example code which uses a list is "sumalist.tm". This example uses IntegerList (a type which doesn't appear in the doku).
When I use Int32List, the mprep result requires a function with an extra integer argument (not long as written in the doku). When I use the undocumented IntegerList type, the extra argument is of type long.
During my experiments with scalar types, I had a similar problem - a c++ function was called properly when using "Integer" in the tm-file, and not recognized with "Integer32".
The "sumalist.tm" example also uses a strange Pattern (list:{___Integer}) about which I didn't find any documentation. I'd also like to understand what the Evaluate line means (I suspect that it's used make the function callable without the curly braces around the list).
So who know which datatypes are really appropriate to call a c++ function with a list - maybe also with reals... ?
I don't know much about MathLink, but I can explain the pattern,
list:{___Integer}.The colon is just the general form for a named pattern, that is
symbol:patternjust says that the object referred to bysymbolhas to matchpattern. Indeed, pattern likea_Integerorb__Listare really just short forms fora:_Integerandb:__List.So what we are left with interpreting is
{___Integer}. This is a pattern matching a list of arbitrary many (including zero) integers. It works as follows:{Pattern}is the Pattern for a list whose contents matchesPattern___Integeris the Pattern for a sequence of zero or moreIntegers.