[Lazarus] Reading std::ostream from dll

Marco van de Voort marcov at stack.nl
Thu Nov 25 12:43:08 CET 2010


On Tue, Nov 23, 2010 at 05:18:38PM -0300, Leonardo M. Ram? wrote:
> Hi, I'm working with a dll/so created with C++, that has a function which
> fills an std::ostream, and I need to read it from a FreePascal app using
> a buffer or TStream.
> 
> The C++ method is similar to this:
> 
> void myClass::getOutputData(ostream &out);
> 
> I wrapped it to be readable from FPC as this:
> ...
> extern "C"{
>   void getMyOutputData(void * myInstance, void * &stream){
>     myClass * lInstance = (myClass *)myInstance;
>     lInstance->getOutputData(stream);
>   }
> }
> ...
> 
> Is there a way to read std::ostream from FPC?

No. This kind of stuff doesn't even work between two different C++ compilers.

You probably need to expose this on C level as a proceure that writes "n"
bytes to a handle. Then the implementation (in C++) should write that block
of mem to the stream.




More information about the Lazarus mailing list