views:

33

answers:

1

hello,

I have written a dll in VC++. I wanted to ask if it is possible for a method in a dll to return an array?

And would that array returned, be compatible with any language that is using the DLL? As-In compatible with C#, Java...etc.

I would be glad if I could get some leads in to it.

thank you.

+1  A: 

Yes, that's absolutely possible.

The easiest approach from a memory allocation point of view is to let the caller pass in two parameters - a buffer where you write the array to and an integer indicating the size of the buffer. That way you don't have to worry about using the same allocator in the DLL and in the caller to allocate and free the memory.

Mattias S