From 95ac0e61b2756b17dc579ff70295478986cad889 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 16 Jun 2015 07:13:45 -0400 Subject: [PATCH] Fix MinGW compiler error, bug927. --- Changes | 2 +- include/verilated_vpi.h | 8 ++++---- include/verilatedos.h | 4 +++- test_regress/t/TestSimulator.h | 9 ++++++--- test_regress/t/t_dist_portability.pl | 9 +++++---- test_regress/t/t_trace_cat.cpp | 6 +++--- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index 5611ec91e..7129dd0b9 100644 --- a/Changes +++ b/Changes @@ -5,7 +5,7 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.875 devel -**** Fix MinGW compiler error, bug929. [Hans Tichelaar] +**** Fix MinGW compiler error, bug927, bug929. [Hans Tichelaar] **** Fix .c files to be treated as .cpp, bug930. [Jonathon Donaldson] diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 824df3e99..e5fc4fc45 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -920,10 +920,10 @@ void vpi_get_value(vpiHandle object, p_vpi_value value_p) { value_p->value.str = outStr; switch (vop->varp()->vltype()) { // outStrSz does not include NULL termination so add one - case VLVT_UINT8 : snprintf(outStr, outStrSz+1, "%hhu", (unsigned char )*((CData*)(vop->varDatap()))); return; - case VLVT_UINT16: snprintf(outStr, outStrSz+1, "%hu", (unsigned short)*((SData*)(vop->varDatap()))); return; - case VLVT_UINT32: snprintf(outStr, outStrSz+1, "%u", (unsigned int )*((IData*)(vop->varDatap()))); return; - case VLVT_UINT64: snprintf(outStr, outStrSz+1, "%llu", (unsigned long long)*((QData*)(vop->varDatap()))); return; + case VLVT_UINT8 : VL_SNPRINTF(outStr, outStrSz+1, "%hhu", (unsigned char )*((CData*)(vop->varDatap()))); return; + case VLVT_UINT16: VL_SNPRINTF(outStr, outStrSz+1, "%hu", (unsigned short)*((SData*)(vop->varDatap()))); return; + case VLVT_UINT32: VL_SNPRINTF(outStr, outStrSz+1, "%u", (unsigned int )*((IData*)(vop->varDatap()))); return; + case VLVT_UINT64: VL_SNPRINTF(outStr, outStrSz+1, "%llu", (unsigned long long)*((QData*)(vop->varDatap()))); return; default: strcpy(outStr, "-1"); _VL_VPI_ERROR(__FILE__, __LINE__, "%s: Unsupported format (%s) for %s, maximum limit is 64 bits", diff --git a/include/verilatedos.h b/include/verilatedos.h index 83f41be4c..07bc007d3 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -207,7 +207,8 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type # endif #endif -#ifdef _WIN32 +#if defined(_WIN32) && defined(_MSC_VER) +# define VL_SNPRINTF _snprintf # define VL_VSNPRINTF vl_vsnprintf inline int vl_vsnprintf(char* str, size_t size, const char* format, va_list ap) { int count = -1; @@ -220,6 +221,7 @@ inline int vl_vsnprintf(char* str, size_t size, const char* format, va_list ap) return count; } #else +# define VL_SNPRINTF snprintf # define VL_VSNPRINTF vsnprintf #endif diff --git a/test_regress/t/TestSimulator.h b/test_regress/t/TestSimulator.h index 849fe1d2a..daa5ae1a1 100644 --- a/test_regress/t/TestSimulator.h +++ b/test_regress/t/TestSimulator.h @@ -14,6 +14,7 @@ //************************************************************************* #include "vpi_user.h" +#include class TestSimulator { private: @@ -69,9 +70,11 @@ public: } // return absolute scope of obj static const char* rooted(const char *obj) { - static char buf[256]; - snprintf(buf, sizeof(buf), "%s.%s", top(), obj); - return buf; + static string buf; + ostringstream os; + os<