digitalmars.D.learn - Call of C function breaks memoty layout
- Andrey (9/14) Jan 24 2020 Hello,
- Steven Schveighoffer (4/20) Jan 24 2020 Not used Tcl in a long time, never via D.
- drug (3/19) Jan 24 2020 I don't know if it is the reason but Tcl_Interp definitely should be
- Steven Schveighoffer (4/23) Jan 24 2020 It shouldn't matter if you are passing an opaque pointer what the struct...
- Steven Schveighoffer (3/19) Jan 24 2020 There's also this: https://code.dlang.org/packages/tcltk
Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I comment the call - I get normal execution. May be somebody had faced with such problem. What to do? My code:struct Tcl_Interp; extern (C) { Tcl_Interp* Tcl_CreateInterp() nothrow; }
Jan 24 2020
On 1/24/20 8:37 AM, Andrey wrote:Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I comment the call - I get normal execution. May be somebody had faced with such problem. What to do? My code:Not used Tcl in a long time, never via D. Have a look at https://wiki.tcl-lang.org/page/D for some instruction maybe? -Stevestruct Tcl_Interp; extern (C) { Tcl_Interp* Tcl_CreateInterp() nothrow; }
Jan 24 2020
On 1/24/20 4:37 PM, Andrey wrote:Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I comment the call - I get normal execution. May be somebody had faced with such problem. What to do? My code:I don't know if it is the reason but Tcl_Interp definitely should be extern(C) too in generalstruct Tcl_Interp; extern (C) { Tcl_Interp* Tcl_CreateInterp() nothrow; }
Jan 24 2020
On 1/24/20 9:58 AM, drug wrote:On 1/24/20 4:37 PM, Andrey wrote:It shouldn't matter if you are passing an opaque pointer what the struct layout actually is. -SteveHello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I comment the call - I get normal execution. May be somebody had faced with such problem. What to do? My code:I don't know if it is the reason but Tcl_Interp definitely should be extern(C) too in generalstruct Tcl_Interp; extern (C) { Tcl_Interp* Tcl_CreateInterp() nothrow; }
Jan 24 2020
On 1/24/20 8:37 AM, Andrey wrote:Hello, I'm trying to bind C library for Tcl/Tk in D code. There is a function called "Tcl_CreateInterp()" which I declared as extent(C). When I call this function then layout of memory become broken - one of my global wstring variables loses it's value. I don't know why it is happens. If I comment the call - I get normal execution. May be somebody had faced with such problem. What to do? My code:There's also this: https://code.dlang.org/packages/tcltk -Stevestruct Tcl_Interp; extern (C) { Tcl_Interp* Tcl_CreateInterp() nothrow; }
Jan 24 2020