From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Andy Parkins <andyparkins@gmail.com>, git@vger.kernel.org
Subject: Re: Numeric constants as strings
Date: Mon, 19 Feb 2007 04:49:55 -0500 [thread overview]
Message-ID: <20070219094955.GE30030@spearce.org> (raw)
In-Reply-To: <7virdy8p25.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
> Andy Parkins <andyparkins@gmail.com> writes:
>
> > I'm working on bringing my hash width literals patch up to
> > date now that 1.5.0 has passed. It's all been trivial apart
> > from one line:
> >
> > #define HASH_WIDTH_ASCII 40
> > - printf("%-40s %s%s (%d subtrees)\n",
> > + printf("%-" HASH_WIDTH_ASCII "s %s%s (%d subtrees)\n",
> >
> > This compiles, but I suspect that it's not going to do what I
> > want it to do.
>
> Doesn't writing "foo" "bar" (two string literals next to each other)
> tell the compiler to concatenate them?
Yes, but here HASH_WIDTH_ASCII is a number... wtf is the compiler
generating for the following?
printf("%-" 40 "s %s%s (%d subtrees)\n",
I did not even realize that was legal C... Now if the 40 was in
quotes (e.g. "40") then the concatenate rule would apply and we
would get a nice argument to printf.
--
Shawn.
next prev parent reply other threads:[~2007-02-19 9:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-19 9:16 Numeric constants as strings Andy Parkins
2007-02-19 9:38 ` Junio C Hamano
2007-02-19 9:49 ` Shawn O. Pearce [this message]
2007-02-19 10:01 ` Matthieu Moy
2007-02-19 10:54 ` Andy Parkins
2007-02-19 10:14 ` Andy Parkins
2007-02-19 9:49 ` Junio C Hamano
2007-02-19 11:00 ` Andy Parkins
2007-02-19 10:04 ` Mark Wooding
2007-02-19 11:02 ` Andy Parkins
2007-02-20 13:06 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070219094955.GE30030@spearce.org \
--to=spearce@spearce.org \
--cc=andyparkins@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.