From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: Re: Numeric constants as strings
Date: Mon, 19 Feb 2007 10:54:58 +0000 [thread overview]
Message-ID: <200702191055.00203.andyparkins@gmail.com> (raw)
In-Reply-To: <vpq1wkm31q4.fsf@olympe.imag.fr>
On Monday 2007 February 19 10:01, Matthieu Moy wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > 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.
>
> I suppose the solution is to use #HASH_WIDTH_ASCII to tell the
> preprocessor to put the quotes around HASH_WIDTH_ASCII.
I'm afraid that only works when you're token pasting parameters in a #define
macro.
For example:
#define macro(x) "foo" #x "baz"
Then, macro(bar) expands to "foo" "bar" "baz". However, the following does
not work:
#define BAR bar
#define macro "foo" #BAR "baz"
This is because BAR is not a macro parameter. I've also tried it indirectly:
#define BAR bar
#define MAKESTRING(x) #x
#define macro "foo" MAKESTRING(BAR) "baz"
But this expands to "foo" "BAR" "baz". Also wrong. Equally, using # anywhere
but during a #define doesn't work, so I can't simply write
printf( "%-" #HASH_WIDTH_ASCII "s", string );
Woe is me. :-(
Andy
--
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com
next prev parent reply other threads:[~2007-02-19 10:55 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
2007-02-19 10:01 ` Matthieu Moy
2007-02-19 10:54 ` Andy Parkins [this message]
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=200702191055.00203.andyparkins@gmail.com \
--to=andyparkins@gmail.com \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).