Skip to content

Commit

Permalink
msvc: make MSVC shutup on strncpy()
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed May 27, 2014
1 parent dc1af54 commit 2a33afe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion arch/XCore/XCoreInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ void XCore_insn_extract(MCInst *MI, char *code)
char *p, *p2;
char tmp[128];

// make MSVC shutup on strncpy()
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
strncpy(tmp, code, strlen(code)); // safe because code is way shorter than 128 bytes
#ifdef _MSC_VER
#pragma warning(pop)
#endif

// find the first space
strcpy(tmp, code);
p = strchr(tmp, ' ');
if (p) {
p++;
Expand Down
3 changes: 1 addition & 2 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
#include "include/capstone.h"
#include "cs_priv.h"

// strcasecmp() & strcpy() for MSVC
// strcasecmp() for MSVC
#if !defined(__MINGW32__) && !defined(__MINGW64__) // this is not MingW
#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)

// string.h
#define strcasecmp _stricmp
#define strcpy strcpy_s

#endif // MSVC
#endif // not MingW
Expand Down

0 comments on commit 2a33afe

Please sign in to comment.