Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Passing Lists to C (Mathlink)' topicStudent Support Forum > General > "Passing Lists to C (Mathlink)"

Help | Reply To Topic
Author Comment/Response
04/13/12 07:05am

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 ( 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 "". This example uses IntegerList (a type which doesn't appear in the docu).

When I use Int32List, the mprep result requires a function with an extra integer argument (not long as written in the docu). When I use the undocumented IntegerList type, the extra argument is of type long.

During my experiments with scalar types, I had the same problem - a c++ function was called properly when using "Integer" in the tm-file, and not recognized with "Integer32".

The "" example also uses a strange Pattern (list:{___Integer}) which is documented nowhere. 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 please tell me which datatypes are really appropriate to call a c++ function with a list - maybe also with reals... ?

URL: ,
Help | Reply To Topic