[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problems with PRIdMAX processing
From: |
Michael Wardle |
Subject: |
problems with PRIdMAX processing |
Date: |
Mon, 03 Nov 2003 12:07:21 +1000 |
Machine: powerpc
Machine Type: powerpc-ibm-aix4.3.3.0
Compiler: gcc
Compiler Version: 2.9-aix43-010414
Bash Version: 2.05b
Description:
When attempting to do a "make" at the top level on an AIX host,
I get this error message when making printf.o:
------------------------------------------------------------
./mkbuiltins -D . printf.def
gcc -c -DHAVE_CONFIG_H -DSHELL -I. -I.. -I.. -I../include
-I../lib -I. -g -O2 printf.c || ( rm -f printf.c ; exit 1 )
./printf.def: In function `printf_builtin':
./printf.def:347: parse error before `%'
./printf.def:374: parse error before `%'
------------------------------------------------------------
I noticed a number of problems:
1.
The generated printf.c is attempting to call sizeof (PRIdMAX).
GNU libc /usr/include/inttypes.h says PRIdMAX is a "macro for
printing `intmax_t'". The corresponding type that should be
supplied as the parameter to sizeof therefore is "intmax_t".
2.
The second instance should use use PRIuMAX and uintmax_t rather
than PRIdMAX and intmax_t, as it comes after a call to getuintmax.
3.
The preprocessor replaces PRIdMAX with %lld rather than the
desired "lld" (determined by running the same compilation command,
replacing -c with -E). This appears to be the root cause of the
problem.
Fix:
The included patch fixes the first problem. The fix for the second
problem should be fairly simple. I am currently unsure how to fix
the third, but it should also be fairly simple for somebody who
understands preprocessing well.
------------------------------------------------------------
diff -ur bash-2.05b/builtins/printf.def
bash-2.05b.lld/builtins/printf.def
--- bash-2.05b/builtins/printf.def Tue May 14 04:36:04 2002
+++ bash-2.05b.lld/builtins/printf.def Mon Nov 3 11:27:07 2003
@@ -344,7 +344,7 @@
p = pp = getintmax ();
if (p != pp)
{
- f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2);
+ f = mklong (start, PRIdMAX, sizeof (intmax_t) - 2);
PF (f, pp);
}
else
@@ -371,7 +371,7 @@
p = pp = getuintmax ();
if (p != pp)
{
- f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2);
+ f = mklong (start, PRIdMAX, sizeof (intmax_t) - 2);
PF (f, pp);
}
else
------------------------------------------------------------
--
Michael Wardle
http://www.endbracket.net/michael/
michael@endbracket.net
+61-415-439-838
- problems with PRIdMAX processing,
Michael Wardle <=