Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

Issue #1413

Wrong printf/scanf format specifiers used for MinGW targets

Added by Sergey Kvachonok 5 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
Configure/Make/Compiling
% Done:

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.

0001-Fix-printf-scanf-format-specifiers-for-modern-MinGW-.patch View (2.15 KB) Sergey Kvachonok, 04/02/2019 12:16 PM

History

#1 Updated by Wilson Snyder 5 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.

#2 Updated by Wilson Snyder 3 months ago

  • Status changed from Resolved to Closed

In 4.014.

Also available in: Atom