diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-09 18:25:10 +0000 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-17 21:17:32 +0000 |
| commit | 22d2062d954dcb88fa3dc65281d3f3d88ae87d68 (patch) | |
| tree | 22852e22d6c571be8ccc1cdaece3d926360fc191 /include/git2/common.h | |
| parent | 57b753a0dc0db2d89341300470653e8a4d066c0b (diff) | |
| download | libgit2-22d2062d954dcb88fa3dc65281d3f3d88ae87d68.tar.gz | |
Introduce GIT_CALLBACK macro to enforce cdecl
Since we now always build the library with cdecl calling conventions,
our callbacks should be decorated as such so that users will not be able
to provide callbacks defined with other calling conventions.
The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as
appropriate.
Diffstat (limited to 'include/git2/common.h')
| -rw-r--r-- | include/git2/common.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index b97f9ef8a..8d3d3c111 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -48,6 +48,13 @@ typedef size_t size_t; # define GIT_EXTERN(type) extern type #endif +/** Declare a callback function for application use. */ +#if defined(_MSC_VER) +# define GIT_CALLBACK(name) (__cdecl *name) +#else +# define GIT_CALLBACK(name) (*name) +#endif + /** Declare a function as deprecated. */ #if defined(__GNUC__) # define GIT_DEPRECATED(func) \ |
