From: Nathan Binkert Date: Mon, 18 Dec 2006 22:07:52 +0000 (-0800) Subject: cast chars to int when we want to print integers so we get a number X-Git-Tag: m5_2.0_beta3~224^2~45 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b40a13728236f1d1d89d5a2169dab28f537d18c;p=gem5.git cast chars to int when we want to print integers so we get a number instead of a character --HG-- extra : convert_revision : 7bfa88ba23ad057b751eb01a80416d9f72cfe81a --- diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh index 58ee7f795..3ea20446d 100644 --- a/src/base/cprintf_formats.hh +++ b/src/base/cprintf_formats.hh @@ -288,13 +288,13 @@ format_integer(std::ostream &out, const T &data, Format &fmt) { _format_integer(out, data, fmt); } inline void format_integer(std::ostream &out, char data, Format &fmt) -{ _format_integer(out, data, fmt); } +{ _format_integer(out, (int)data, fmt); } inline void format_integer(std::ostream &out, unsigned char data, Format &fmt) -{ _format_integer(out, data, fmt); } +{ _format_integer(out, (int)data, fmt); } inline void format_integer(std::ostream &out, signed char data, Format &fmt) -{ _format_integer(out, data, fmt); } +{ _format_integer(out, (int)data, fmt); } #if 0 inline void format_integer(std::ostream &out, short data, Format &fmt) diff --git a/src/unittest/cprintftest.cc b/src/unittest/cprintftest.cc index 9c3eb0cd6..a05426356 100644 --- a/src/unittest/cprintftest.cc +++ b/src/unittest/cprintftest.cc @@ -43,6 +43,7 @@ main() char foo[9]; cprintf("%s\n", foo); + cprintf("%d\n", 'A'); cprintf("%shits%%s + %smisses%%s\n", "test", "test"); cprintf("%%s%-10s %c he went home \'\"%d %#o %#x %1.5f %1.2E\n", "hello", 'A', 1, 0xff, 0xfffffffffffffULL, 3.141592653589, 1.1e10);