Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
wish that ocamlopt compile .cpp files as well as c files #5823
Original bug ID: 5823
I tried the following very simple patch that seems to work :
diff -ur ocaml-4.00.1/driver/main.ml ocaml-4.00.1_patched/driver/main.ml
and add the following rule for ocamlbuild:
Comment author: @damiendoligez
Your patch won't work because you failed to change the calls to "chop_suffix". Also, this would change the requirements on configure from "find a C compiler" to "find something that can indifferently compile C and C++". I'm not sure if that is a big deal or not, but it has to be considered.
Comment author: @whitequark
This patch is not enough because it won't link the C++ standard library. The only remotely portable way to do so is to remember whether C++ files were used during compiling and invoke g++ (or equivalent) instead of gcc (or equivalent) during linking.
Alternatively you could try detecting how the standard library is named (nontrivial; current OS X has two) and putting it in cma's autolink flags, but I'm not sure if that's a simpler choice.