[pacman-dev] [PATCH] Fix compile error with clang-2.8
Signed-off-by: Allan McRae <allan@archlinux.org> --- wint_t appears to be the same as size_t or unsigned long. It probably best if someone checks that is the right format specifier on x86_64 too... src/pacman/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 5b4b2e8..8dc1571 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -261,7 +261,7 @@ void indentprint(const char *str, int indent) } continue; } - printf("%lc", (wint_t)*p); + printf("%u", (wint_t)*p); cidx += wcwidth(*p); p++; } -- 1.7.3.1
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae <allan@archlinux.org> wrote:
Signed-off-by: Allan McRae <allan@archlinux.org> ---
wint_t appears to be the same as size_t or unsigned long. It probably best if someone checks that is the right format specifier on x86_64 too...
man wchar.h: The implementation shall support one or more programming environments in which the width of wint_t is no greater than the width of type long. man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument. So we should really be using '%lc', it sounds like clang is busted... What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
src/pacman/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c index 5b4b2e8..8dc1571 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -261,7 +261,7 @@ void indentprint(const char *str, int indent) } continue; } - printf("%lc", (wint_t)*p); + printf("%u", (wint_t)*p); cidx += wcwidth(*p); p++; } -- 1.7.3.1
On Thu, Oct 7, 2010 at 7:50 AM, Dan McGee <dpmcgee@gmail.com> wrote:
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae <allan@archlinux.org> wrote:
Signed-off-by: Allan McRae <allan@archlinux.org> ---
wint_t appears to be the same as size_t or unsigned long. It probably best if someone checks that is the right format specifier on x86_64 too...
man wchar.h: The implementation shall support one or more programming environments in which the width of wint_t is no greater than the width of type long.
man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument.
So we should really be using '%lc', it sounds like clang is busted...
What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
And it may have been solved already... http://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg26807.html -Dan
On 07/10/10 22:51, Dan McGee wrote:
On Thu, Oct 7, 2010 at 7:50 AM, Dan McGee<dpmcgee@gmail.com> wrote:
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae<allan@archlinux.org> wrote:
Signed-off-by: Allan McRae<allan@archlinux.org> ---
wint_t appears to be the same as size_t or unsigned long. It probably best if someone checks that is the right format specifier on x86_64 too...
man wchar.h: The implementation shall support one or more programming environments in which the width of wint_t is no greater than the width of type long.
man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument.
So we should really be using '%lc', it sounds like clang is busted...
What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
And it may have been solved already... http://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg26807.html
Well, that was fast! I had not even reported a bug yet...
On 07/10/10 22:50, Dan McGee wrote:
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae<allan@archlinux.org> wrote:
Signed-off-by: Allan McRae<allan@archlinux.org> ---
wint_t appears to be the same as size_t or unsigned long. It probably best if someone checks that is the right format specifier on x86_64 too...
man wchar.h: The implementation shall support one or more programming environments in which the width of wint_t is no greater than the width of type long.
man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument.
So we should really be using '%lc', it sounds like clang is busted...
What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
Same error with %ls. util.c:264:13: error: conversion specifies type 'int *' but the argument has type 'wint_t' (aka 'unsigned int') [-Wformat] printf("%ls", (wint_t)*p); ~~^ ~~~~~~~~~~ %u 1 error generated.
Allan McRae <allan@archlinux.org> wrote:
On 07/10/10 22:50, Dan McGee wrote:
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae<allan@archlinux.org> wrote:
man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument.
So we should really be using '%lc', it sounds like clang is busted...
What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
Same error with %ls.
util.c:264:13: error: conversion specifies type 'int *' but the argument has type 'wint_t' (aka 'unsigned int') [-Wformat] printf("%ls", (wint_t)*p); ~~^ ~~~~~~~~~~ %u 1 error generated.
I may be a C newbie, but is (wint_t)*p the same as (wint_t)(*p) ? It would explain the pointer/integer confusion.
On Thu, Oct 7, 2010 at 8:05 AM, Rémy Oudompheng <remyoudompheng@gmail.com> wrote:
Allan McRae <allan@archlinux.org> wrote:
On 07/10/10 22:50, Dan McGee wrote:
On Wed, Oct 6, 2010 at 8:40 PM, Allan McRae<allan@archlinux.org> wrote:
man printf(3): l (ell) A following integer conversion corresponds to a long int or unsigned long int argument, or a following n conversion corre‐ sponds to a pointer to a long int argument, or a following c conversion corresponds to a wint_t argument, or a following s con‐ version corresponds to a pointer to wchar_t argument.
So we should really be using '%lc', it sounds like clang is busted...
What does printf("%ls", p) give you? This isn't actually right because we don't want to print the full string, just one character, but it would be interesting to see if they implemented half of the spec.
Same error with %ls.
util.c:264:13: error: conversion specifies type 'int *' but the argument has type 'wint_t' (aka 'unsigned int') [-Wformat] printf("%ls", (wint_t)*p); ~~^ ~~~~~~~~~~ %u 1 error generated.
I may be a C newbie, but is (wint_t)*p the same as (wint_t)(*p) ? It would explain the pointer/integer confusion.
printf("%ls", (wint_t)*p); != printf("%ls", p) And the mailing list message I mentioned seemed old enough that it should have snuck into clang 2.8... -Dan
participants (3)
-
Allan McRae
-
Dan McGee
-
Rémy Oudompheng