Re: [Lazarus] Library function trashing object

2013-04-20 Thread Lubos Pintes
Yet another thing, someone also mentioned this. The cdecl calling convention corresponds to extern "C" in C++. Maybe you are using stdcall in your C++ library? Or perhaps you are on Linux where this is not relevant? But the extern "C" could be relevant also on Linux. Dňa 19. 4. 2013 21:24 Lubo

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Hans-Peter Diettrich
Leonardo M. Ramé schrieb: On 2013-04-19 21:08:29 +0200, Lubos Pintes wrote: I probably don't understand. You will be able to change it, I see no problem. It is a local variable which can be changed. You're right, C++ "&" is equivalent to Pascal "var". Well, removing the "var" in the 2nd para

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Leonardo M . Ramé
On 2013-04-19 21:24:50 +0200, Lubos Pintes wrote: > This is How I understand the var parameter. > It is an address, but is treated as normal variable, so it is not > needed to dereference a pointer. > For example > int f(int* x) in C/C++ corresponds to > function f(var x: integer): integer; > Now w

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Lubos Pintes
This is How I understand the var parameter. It is an address, but is treated as normal variable, so it is not needed to dereference a pointer. For example int f(int* x) in C/C++ corresponds to function f(var x: integer): integer; Now we have int f(int x); If you declare it as function f(var x: i

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Leonardo M . Ramé
On 2013-04-19 21:08:29 +0200, Lubos Pintes wrote: > I probably don't understand. You will be able to change it, I see no > problem. It is a local variable which can be changed. > > Dňa 19. 4. 2013 20:55 Leonardo M. Ramé wrote / napísal(a): > >On 2013-04-19 20:52:04 +0200, Lubos Pintes wrote: > >>I

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Lubos Pintes
I probably don't understand. You will be able to change it, I see no problem. It is a local variable which can be changed. Dňa 19. 4. 2013 20:55 Leonardo M. Ramé wrote / napísal(a): On 2013-04-19 20:52:04 +0200, Lubos Pintes wrote: I think you could not declare the second parameter of GetData

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Leonardo M . Ramé
On 2013-04-19 20:52:04 +0200, Lubos Pintes wrote: > I think you could not declare the second parameter of GetData as var > parameter. Because it is then treated as address. > I am not sure what corresponds to C++ unsigned long, perhaps LongWord? > So try to change the second parameter so that it is

Re: [Lazarus] Library function trashing object

2013-04-19 Thread Lubos Pintes
I think you could not declare the second parameter of GetData as var parameter. Because it is then treated as address. I am not sure what corresponds to C++ unsigned long, perhaps LongWord? So try to change the second parameter so that it is not a var parameter. Dňa 19. 4. 2013 19:18 Leonardo M.

[Lazarus] Library function trashing object (was: SIGSEGV when trying to use a TCustomControl)

2013-04-19 Thread Leonardo M . Ramé
I'm using a C++ library with a function that receives a parameter this way: int getData(void * &buffer, unsigned long &bufSize){ bufSize = 10; return 1; } The Pascal definition I'm using is this: function (var buffer: pointer; var bufsize: longword): Integer; cdecl; I'm using this library w