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);