summaryrefslogtreecommitdiff
path: root/tests/apis/namespace/includes/src
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-09 10:19:14 +0800
committerGitHub <[email protected]>2025-01-09 10:19:14 +0800
commit8e24b5a44dcffbee1444d715909a64014e11e866 (patch)
treea2f0aaf7b582dae30d4db636efd199ccb158e0d8 /tests/apis/namespace/includes/src
parent1cf6a7f479837b471a5f91410359d86983828e6a (diff)
parent6317ffd0fe312360eb5f6e079320c01c95870ad0 (diff)
Merge pull request #6001 from xmake-io/namespace
Support for namespace
Diffstat (limited to 'tests/apis/namespace/includes/src')
-rw-r--r--tests/apis/namespace/includes/src/bar.cpp5
-rw-r--r--tests/apis/namespace/includes/src/bar.h9
-rw-r--r--tests/apis/namespace/includes/src/foo.cpp5
-rw-r--r--tests/apis/namespace/includes/src/foo.h9
-rw-r--r--tests/apis/namespace/includes/src/main.cpp9
-rw-r--r--tests/apis/namespace/includes/src/xmake.lua8
6 files changed, 45 insertions, 0 deletions
diff --git a/tests/apis/namespace/includes/src/bar.cpp b/tests/apis/namespace/includes/src/bar.cpp
new file mode 100644
index 000000000..2c00cc6b6
--- /dev/null
+++ b/tests/apis/namespace/includes/src/bar.cpp
@@ -0,0 +1,5 @@
+#include "bar.h"
+
+int sub(int a, int b) {
+ return a - b;
+}
diff --git a/tests/apis/namespace/includes/src/bar.h b/tests/apis/namespace/includes/src/bar.h
new file mode 100644
index 000000000..47d8a7251
--- /dev/null
+++ b/tests/apis/namespace/includes/src/bar.h
@@ -0,0 +1,9 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int sub(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/apis/namespace/includes/src/foo.cpp b/tests/apis/namespace/includes/src/foo.cpp
new file mode 100644
index 000000000..1a1fb3425
--- /dev/null
+++ b/tests/apis/namespace/includes/src/foo.cpp
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+int add(int a, int b) {
+ return a + b;
+}
diff --git a/tests/apis/namespace/includes/src/foo.h b/tests/apis/namespace/includes/src/foo.h
new file mode 100644
index 000000000..d2506bca9
--- /dev/null
+++ b/tests/apis/namespace/includes/src/foo.h
@@ -0,0 +1,9 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/apis/namespace/includes/src/main.cpp b/tests/apis/namespace/includes/src/main.cpp
new file mode 100644
index 000000000..4cf7b5e62
--- /dev/null
+++ b/tests/apis/namespace/includes/src/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+#include "bar.h"
+#include <iostream>
+
+int main(int argc, char** argv) {
+ std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
+ std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl;
+ return 0;
+}
diff --git a/tests/apis/namespace/includes/src/xmake.lua b/tests/apis/namespace/includes/src/xmake.lua
new file mode 100644
index 000000000..1d93e5a9a
--- /dev/null
+++ b/tests/apis/namespace/includes/src/xmake.lua
@@ -0,0 +1,8 @@
+namespace("ns2", function ()
+ add_defines("NS2_ROOT")
+ target("bar")
+ set_kind("static")
+ add_files("bar.cpp")
+ add_defines("BAR")
+end)
+