summaryrefslogtreecommitdiff
path: root/build2/cxx-modules/modtest/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/cxx-modules/modtest/driver.cxx')
-rw-r--r--build2/cxx-modules/modtest/driver.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/build2/cxx-modules/modtest/driver.cxx b/build2/cxx-modules/modtest/driver.cxx
new file mode 100644
index 0000000..e782e85
--- /dev/null
+++ b/build2/cxx-modules/modtest/driver.cxx
@@ -0,0 +1,51 @@
+// file : driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+//#include <string>
+#include <iostream>
+
+// For macro isolation test.
+//
+#define MODTEST_MACRO 2
+
+// VC introduces module-related declarations (import, export, module). CLang
+// doesn't do that implementing some transitional model interpreting headers as
+// modules according to a special "module.modulemap" file and performing import
+// in place of #include.
+//
+#if defined(MODTEST_USE_MODULES) && defined(_MSC_VER)
+
+import foo;
+import bar;
+
+#else
+
+# include <foo>
+# include <bar>
+
+// If we are using modules and #include directive is effectivelly converted to
+// the import declaration there should be no "redefinition of foo" error. Let's
+// check that.
+//
+# ifdef MODTEST_USE_MODULES
+# include <foo>
+# endif
+
+#endif
+
+using namespace std;
+
+int
+main ()
+{
+ foo f (3);
+ cerr << "foo values: " << foo_value (5) << " " << f.value () << endl
+ << "foo macros: "
+ << (MODTEST_MACRO == f.macro () ? "leaks" : "isolated") << endl;
+
+// cerr << f.message ("Hi") << endl;
+
+ bar b (7);
+ cerr << "bar values: " << bar_value (6) << " " << b.value () << endl;
+}