summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--translate.cxx14
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b780b068..53aec96b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-06 Graydon Hoare <graydon@redhat.com>
+
+ * translate.cxx (visit_print_format): Explicitly Cast int64_t
+ (pe_long) args to (long long) in generated code, for portability.
+
2005-12-05 Frank Ch. Eigler <fche@elastic.org>
* *.cxx: Add <cassert> #include as needed.
diff --git a/translate.cxx b/translate.cxx
index ee1eff41..e84f9373 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -3154,7 +3154,19 @@ c_unparser::visit_print_format (print_format* e)
for (unsigned i = 0; i < tmp.size(); ++i)
{
- o->line() << ", " << tmp[i].qname();
+ // We must cast our pe_long type (which is int64_t) to "long
+ // long" here, because the format string type we are using
+ // is %ll. We use this format string because, at the back
+ // end of vsnprintf, linux actually implements it using the
+ // "long long" type as well, not a particular 32 or 64 bit
+ // width, and it *also* fails to provide any inttype.h-like
+ // macro machinery to figure out how many bits exist in a
+ // long long. Using %ll and always casting the argument is
+ // the most portable target-sensitive solution.
+ if (tmp[i].type() == pe_long)
+ o->line() << ", ((long long)(" << tmp[i].qname() << "))";
+ else
+ o->line() << ", " << tmp[i].qname();
}
o->line() << ");";
o->newline() << res.qname() << ";";