diff options
author | Sascha Cunz <sascha@babbelbox.org> | 2012-05-11 04:25:23 +0200 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-05-14 20:22:50 +0200 |
commit | 1093e2de22f6ca245b09d758a3510899a8362048 (patch) | |
tree | a1ec8e177ad39ec14ad76238703b2632c552cfe2 /include/git2/common.h | |
parent | e49cb1687e7400aeccac161a1b080fdc23897522 (diff) | |
download | libgit2-1093e2de22f6ca245b09d758a3510899a8362048.tar.gz |
Specifiy dllimport to MSVC if we're not building libgit2.dll
Building a "shared object" (DLL) in Windows includes 2 steps:
- specify __declspec(dllexport)
when building the library itself. MSVC will disallow itself from
optimizing these symbols out and reference them in the PE's
Exports-Table.
Further, a static link library will be generated. This library
contains the symbols which are exported via the declsepc above.
The __declspec(dllexport) becomes part of the symbol-signature
(like parameter types in C++ are 'mangled' into the symbol name,
the export specifier is mingled with the name)
- specify __declspec(dllimport)
when using the library. This again mingles the declspec into the
name and declares the function / variable with external linkage.
cmake automatically adds -Dgit2_EXPORTS to the compiler arguments
when compiling the libgit2 project.
The 'git2' is the name specified via PROJECT() in CMakeLists.txt.
Diffstat (limited to 'include/git2/common.h')
-rw-r--r-- | include/git2/common.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index 0e937980..a16cf43d 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -32,7 +32,11 @@ __attribute__((visibility("default"))) \ type #elif defined(_MSC_VER) -# define GIT_EXTERN(type) __declspec(dllexport) type +# ifdef git2_EXPORTS /* defined by cmake */ +# define GIT_EXTERN(type) __declspec(dllexport) type +# else +# define GIT_EXTERN(type) __declspec(dllimport) type +# endif #else # define GIT_EXTERN(type) extern type #endif |