Issue #1413
Wrong printf/scanf format specifiers used for MinGW targets
0%
Description
Modern MinGW C runtime versions (starting from GCC 6) have switched to C99/C++11 compliant printf/scanf format specifiers when <cstdio> include is used.
OTOH, when <stdio.h> include is used, MinGW still defaults to MS formats, but even then it can be overridden with
#define __USE_MINGW_ANSI_STDIO 1
Source: https://sourceforge.net/p/mingw-w64/wiki2/printf%20and%20scanf%20family/
For GCC 5 MinGW and older, <cstdio> behaved just like <stdio.h>.
verilatedos.h header still assumes that MinGW always uses MS formats, which breaks printing of 64-bit numbers on 32-bit MinGW GCC 6, 7 and 8. Compiling verilated.cpp also prints an array of printf format warnings with modern MinGW compilers for the 32-bit Windows target.
I've attached a patch which makes both old and new MinGW compilers use the standard printf formats. Older MinGW versions are just forced to use C99 formats with the above preprocessor definition.
History
#1 Updated by Wilson Snyder 8 months ago
- Category changed from Usage to Configure/Make/Compiling
- Status changed from New to Resolved
- Assignee set to Sergey Kvachonok
Excellent, thanks for the work & patch.
Fixed in git towards 4.014.
Also available in: Atom