You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 224 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
The prototype for copy_string() in caml/alloc.h should (probably) read:
value copy_string (const char *);
It currently reads:
value copy_string (char ); / not right! */
This prevents proper C/OCAML programs from compiling (without great
contortions)
if the compiler is paranoid about dropping type qualifiers (g++ is an example of
such a compiler: this actually bit me in real life, and in C++ it can be
illegal
to cast from "const char *" to "char *" so there is no easy fix). A stub
procedure
trying to copy a C "const char *" (that it got from a library, say) over to an
OCAML
value using the current copy_string() will be unable to because passing it to
copy_string nominally discards the "const" type qualifier. Since copy_string()
does
not (I presume!) actually modify its arguments, it should be declared "const".
This
should not break any current code but will allow more (correct) code to compile.
I
changed it on my local system and it didn't seem to break anything. You may also
want to do something similar for copy_string_array().
- Wes
The text was updated successfully, but these errors were encountered:
Full_Name: Westley Weimer
The prototype for copy_string() in caml/alloc.h should (probably) read:
value copy_string (const char *);
We'll try adding it, but const is generally a pain in the neck because
the contravariance of functions is not handled correctly, so we might
backtrack on this.
such a compiler: this actually bit me in real life, and in C++ it can be
illegal to cast from "const char *" to "char *" so there is no easy fix).
Original bug ID: 224
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Westley Weimer
Version: 3.0.0
OS: linux
Submission from: user-vcaumjr.dsl.mindspring.com (216.175.90.123)
The prototype for copy_string() in caml/alloc.h should (probably) read:
value copy_string (const char *);
It currently reads:
value copy_string (char ); / not right! */
This prevents proper C/OCAML programs from compiling (without great
contortions)
if the compiler is paranoid about dropping type qualifiers (g++ is an example of
such a compiler: this actually bit me in real life, and in C++ it can be
illegal
to cast from "const char *" to "char *" so there is no easy fix). A stub
procedure
trying to copy a C "const char *" (that it got from a library, say) over to an
OCAML
value using the current copy_string() will be unable to because passing it to
copy_string nominally discards the "const" type qualifier. Since copy_string()
does
not (I presume!) actually modify its arguments, it should be declared "const".
This
should not break any current code but will allow more (correct) code to compile.
I
changed it on my local system and it didn't seem to break anything. You may also
want to do something similar for copy_string_array().
The text was updated successfully, but these errors were encountered: