Skip to content

Commit b106620

Browse files
committed
examples: move MSVC compatibility macros into common header
We currently have two locations in our examples where we define the same compatibility wrappers for MSVC. Move them into "common.h" to avoid duplication and make them available to other examples.
1 parent d1cfd79 commit b106620

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

examples/blame.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
#include "common.h"
1616

17-
#ifdef _MSC_VER
18-
#define snprintf sprintf_s
19-
#define strcasecmp strcmpi
20-
#endif
21-
2217
/**
2318
* This example demonstrates how to invoke the libgit2 blame API to roughly
2419
* simulate the output of `git blame` and a few of its command line arguments.

examples/common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
#endif
2727
#endif
2828

29+
#ifdef _MSC_VER
30+
#define snprintf sprintf_s
31+
#define strcasecmp strcmpi
32+
#endif
33+
2934
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*x))
3035
#define UNUSED(x) (void)(x)
3136

examples/merge.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#include "common.h"
1616
#include <assert.h>
1717

18-
#ifdef _MSC_VER
19-
#define snprintf sprintf_s
20-
#endif
21-
2218
/** The following example demonstrates how to do merges with libgit2.
2319
*
2420
* It will merge whatever commit-ish you pass in into the current branch.

0 commit comments

Comments
 (0)