diff options
| author | ruki <[email protected]> | 2016-02-22 08:49:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-02-22 08:49:20 +0800 |
| commit | ec6fd4eeca3fa468cffb25b472eb349c1fed06aa (patch) | |
| tree | 3dbbb42e44310d8ae80ba2361a9f34bbbb90da13 /tests/shared_library_c++/src | |
| parent | 762f3cd87615acbed339931bfb56c2b75c44cfa0 (diff) | |
modify tests script
Diffstat (limited to 'tests/shared_library_c++/src')
| -rwxr-xr-x | tests/shared_library_c++/src/interface.cpp | 6 | ||||
| -rwxr-xr-x | tests/shared_library_c++/src/interface.h | 24 | ||||
| -rwxr-xr-x | tests/shared_library_c++/src/test.cpp | 10 |
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/shared_library_c++/src/interface.cpp b/tests/shared_library_c++/src/interface.cpp new file mode 100755 index 000000000..598d07560 --- /dev/null +++ b/tests/shared_library_c++/src/interface.cpp @@ -0,0 +1,6 @@ +#include "interface.h" + +int add(int a, int b) +{ + return a + b; +} diff --git a/tests/shared_library_c++/src/interface.h b/tests/shared_library_c++/src/interface.h new file mode 100755 index 000000000..ef24ba3ce --- /dev/null +++ b/tests/shared_library_c++/src/interface.h @@ -0,0 +1,24 @@ +#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 + +/*! calculate add(a, b) + * + * @param a the first argument + * @param b the second argument + * + * @return the result + */ +__export int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/shared_library_c++/src/test.cpp b/tests/shared_library_c++/src/test.cpp new file mode 100755 index 000000000..72e03272b --- /dev/null +++ b/tests/shared_library_c++/src/test.cpp @@ -0,0 +1,10 @@ +#include "interface.h" +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "add(1, 2) = " << add(1, 2) << endl; + return 0; +} |
