void* pointers get corrupted: D bug or misunderstanding?

Federico Santamorena federico at santamorena.me
Mon Jul 29 12:42:37 UTC 2019


On Monday, 29 July 2019 at 12:18:51 UTC, Kagamin wrote:
> struct DrillGtkContext
> {
>     static extern(C)
>     void gtk_search_changed(GtkEditable* widget, ref 
> DrillGtkContext context)
>     {
>         context.onSearchChanged();
>     }
>     void onSearchChanged()
>     {
>         ...
>         startCrawling(drillConfig, searchString, &resultFound);
>     }
>     void resultFound(immutable(FileInfo) result)
>     {
>         ...
>         queue.g_async_queue_push(f);
>     }
> }
>
> ...
> DrillContext* startCrawling(
>     in const(DrillConfig) config,
>     in immutable(string) searchValue,
>     scope void delegate(immutable(FileInfo)) resultCallback)
> {
>     ...
>     new Crawler(..., c.callback);
> }

Oooooh I see, I recently switched from C to D and this is a lot 
cleaner

I thought you couldn't use D things like "ref" in extern(C)


More information about the Digitalmars-d mailing list