Skip to content

Commit

Permalink
Add a test-case showing a failure when -std=c++11 is not added to the…
Browse files Browse the repository at this point in the history
… C++ compiler arguments

Signed-off-by: Kate <kit-ty-kate@outlook.com>
  • Loading branch information
kit-ty-kate committed Oct 1, 2024
1 parent 05aa56a commit ac1a332
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/blackbox-tests/test-cases/cxx-flags.t/cpp11.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <caml/misc.h>
#include <caml/mlvalues.h>
#include <iostream>

extern "C" CAMLprim value cpp11(value _unit) {
std::cout << "Hi from C++11" << std::endl;
return Val_unit;
}
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/cxx-flags.t/cpp11.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
external cpp11 : unit -> unit = "cpp11"

let () = cpp11 ()
9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/cxx-flags.t/dune
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@
(= %{architecture} arm64)))
(action
(write-file extra_flags.sexp "(-ccopt -Wl,-no_warn_duplicate_libraries)")))

; will fail if :standard doesn't have -std=c++11 on OCaml >= 5.0
(executable
(name cpp11)
(modules cpp11)
(foreign_stubs
(language cxx)
(names cpp11)
(flags -std=c++98 :standard)))
8 changes: 8 additions & 0 deletions test/blackbox-tests/test-cases/cxx-flags.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ one can extend link flags in env
$ dune rules sub/main.exe --profile some-profile | tr -s '\n' ' ' |
> grep -ce "Main.cmx$GCC_LF_LIB$OTHER\|Main.cmx$Clang_LF_LIB$OTHER\|Main.cmx$Msvc_LF_LIB$OTHER"
1

-std=c++11 is given on OCaml 5.0
================================

$ dune clean

$ dune exec ./cpp11.exe
Hi from C++11

0 comments on commit ac1a332

Please sign in to comment.