Hi,

I'm trying to create bindings to the GraphcicsMagick C library which has the following struct defined:

    #define MaxTextExtent 2053

    typedef struct _Image {
      /* other members skipped */
      char filename[MaxTextExtent];
    } Image;


In an `extern (C)` block I've "converted" the struct to D:

    enum MaxTextExtent = 2053;

    struct Image
    {
      /* other members skipped */
      char[MaxTextExtent] filename;
    }


The problem is trying to set the `filename` member since I can't directly use a D string. I've seen a post which is a similar issue[0], but adapting the code provides an error:
    static assert: "Cannot put a string into a char[2053]"

I've also tried using `new char[MaxTextExtent]` and looping through the string to copy the characters over. This does compile, however, when trying to write the image to disk the provided filename is often a "stripped" version of when you want (e.g. "image.jpg" becomes "g").

[0]: https://forum.dlang.org/thread/lshnzqbfkrhfkliap...@forum.dlang.org

Reply via email to