[fpc-pascal] Question about functions returning a string
ewald at yellowcouch.org
Mon Dec 1 16:10:20 CET 2014
On 12/01/2014 04:34 AM, leledumbo wrote:
>> So in general, one should not use managed types in the prototype of an
>> exported (public) function?
> Bingo. At least not until we have properly sharable RTL.
The problem lies not with a sharable RTL. As mentioned, I do not want to
/use/ these managed types in another language. I just want to pass them
>> my thought was that it would be
>> possible to pass along these managed types (especially string, as it is
>> a pointer internally) to another pascal function (a callback in my case).
> You can still pass pointer to its first element as a PChar, treating it
> read-only in the caller for safety reason (though it's possible to make it
> writable as well, but the safety burden is propagated to the caller).
Actually I was trying to avoid PChar's ;-)
In the meanwhile, I've fixed my issue by not returning a string as a
result, but as an out parameter:
Function Bla: String;
... becomes ...
Procedure Bla(out Result: String);
This seems to work. How portable it is, I do not know, I guess time will
be the judge and jury on that.
Anyway, thanks to you all!
More information about the fpc-pascal