From c3d5b23ac4ae340bcdfe20431340b311cdfc9b44 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Fri, 22 Mar 2019 08:08:29 -0700 Subject: [PATCH] Fix some Windows build issues. --- vvp/config.h.in | 12 ++++++++++++ vvp/vpi_modules.cc | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vvp/config.h.in b/vvp/config.h.in index f21883dbe..3aac6a4c5 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -195,4 +195,16 @@ inline int64_t i64round(double x) #define TU "" #endif +#ifdef __MINGW32__ +# include +static inline char*strndup(const char*s, size_t n) +{ + if (strlen(s) < n) return strdup(s); + char*tmp = (char*)malloc(n); + strncpy(tmp, s, n); + tmp[n-1] = 0; + return tmp; +} +#endif + #endif /* IVL_config_H */ diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 24fa2a309..e91bebe0a 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -102,13 +102,13 @@ void vpip_add_env_and_default_module_paths() s = strrchr(basepath, '\\'); if (s) *s = 0; else { - fprintf(stderr, "%s: Missing first \\ in exe path!\n", argv[0]); + fprintf(stderr, "%s: Missing first \\ in exe path!\n", tmp); exit(1); } s = strrchr(basepath, '\\'); if (s) *s = 0; else { - fprintf(stderr, "%s: Missing second \\ in exe path!\n", argv[0]); + fprintf(stderr, "%s: Missing second \\ in exe path!\n", tmp); exit(1); } strcat(s, "\\lib\\ivl" IVL_SUFFIX);