Search code examples
constantsd

const(char)* cannot be modified


Attempting to change IniFileName to null (to disable .ini saving) yields this error:

Error: cannot modify const expression (*io).IniFilename.

IniFilename is a const char*. It seems like the const is blocking my ability to change it.

I am using DerelictImgui, which is a dynamic binding to cimgui, a wrapper of ImGui.

Is there any way around this so that I can modify IniFilename? Thanks in advance.


Solution

  • You can simply assign to null using

    cast() (*io).IniFilename = null;
    

    the cast() will just remove the modifiers from it so you are able to change it.