diff options
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; +} |
