Repository navigation
Conversation
> `String_val(v)` returns a pointer to the first byte of the string > `v`, with type `char *` or, when OCaml is configured with > `-force-safe-string`, with type `const char *`. https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#ss:c-block-access Safe strings have been the default since OCaml 4.06. https://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html The function CreateProcess has two parameters that are non-const: LPSTR lpCommandLine LPVOID lpEnvironment https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa Passing a const string triggers warnings. One can cast away the const but that does not seem safe, or duplicate the string. Here, I’m duplicating the string.
|
MSDN has:
Given the typical representation of strings in OCaml, do we ever end up in an environment where MSDN is silent on whether either |
|
Note that since 4.06, OCaml itself always uses Unicode versions of functions. It's not related here, but unless you use Windows '95/'98/ME, the ANSI versions of functions are stubs which convert their arguments to Unicode and call the "wide" version. As it happens, that's the explanation for why this only affects Why not upgrade the LWT Unix stubs to use Unicode on Windows? That way you'd be copying anyway because you'll need to use |
|
Thanks @dra27. I agree. We should aim to change Lwt to use the - For right now, I think the best thing to do is cast, and add a comment that this is only valid because we are calling |
https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#ss:c-block-access
Safe strings have been the default since OCaml 4.06.
https://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html
The function CreateProcess has two parameters that are non-const:
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
Passing a const string triggers warnings. One can cast away the const
but that does not seem safe, or duplicate the string. Here, I’m
duplicating the string.