diff options
| author | ruki <[email protected]> | 2026-08-09 18:06:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-08-09 18:06:16 +0800 |
| commit | 5f5daf64c504e1103a355f45bf925a5149b03e24 (patch) | |
| tree | af4d584b3c7badc1df56038cdb29099b4f3e99fd /xmake/templates/c++/shared/src | |
| parent | 6ac4ea833193a4319a1eb6e5f588d1877fd48064 (diff) | |
move templates dir
Diffstat (limited to 'xmake/templates/c++/shared/src')
| -rw-r--r-- | xmake/templates/c++/shared/src/foo.cpp | 5 | ||||
| -rw-r--r-- | xmake/templates/c++/shared/src/foo.h | 17 | ||||
| -rw-r--r-- | xmake/templates/c++/shared/src/main.cpp | 7 |
3 files changed, 29 insertions, 0 deletions
diff --git a/xmake/templates/c++/shared/src/foo.cpp b/xmake/templates/c++/shared/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/xmake/templates/c++/shared/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/xmake/templates/c++/shared/src/foo.h b/xmake/templates/c++/shared/src/foo.h new file mode 100644 index 000000000..bd496c784 --- /dev/null +++ b/xmake/templates/c++/shared/src/foo.h @@ -0,0 +1,17 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) +#define __export __declspec(dllexport) +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +#define __export __attribute__((visibility("default"))) +#else +#define __export +#endif + +__export int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/xmake/templates/c++/shared/src/main.cpp b/xmake/templates/c++/shared/src/main.cpp new file mode 100644 index 000000000..3834ee4d3 --- /dev/null +++ b/xmake/templates/c++/shared/src/main.cpp @@ -0,0 +1,7 @@ +#include "foo.h" +#include <iostream> + +int main(int argc, char **argv) { + std::cout << "add(1, 2) = " << add(1, 2) << std::endl; + return 0; +} |
