git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Numeric constants as strings

From
APAndy Parkins <andyparkins@gmail.com>
Date
Feb 19, 2007, 10:14 UTC
Message-ID
<200702191014.23055.andyparkins@gmail.com>
In-Reply-To
<7virdy8p25.fsf@assigned-by-dhcp.cox.net>
On Monday 2007 February 19 09:38, Junio C Hamano wrote:
Show 9 quoted lines
> > #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?
It's not a string literal though.
It's
 #define HASH_WIDTH_ASCII 40
rather than
 #define HASH_WIDTH_ASCII "40"
I'm wondering how to turn the first into the second using the preprocessor.
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com
Previous: Andy ParkinsNext: Junio C Hamano
Message 6 of 11 in “Numeric constants as strings”
  1. Andy ParkinsFeb 19, 2007
  2. Junio C HamanoFeb 19, 2007
  3. Shawn O. PearceFeb 19, 2007
  4. Matthieu MoyFeb 19, 2007
  5. Andy ParkinsFeb 19, 2007
  6. Andy ParkinsFeb 19, 2007
  7. Junio C HamanoFeb 19, 2007
  8. Andy ParkinsFeb 19, 2007
  9. Mark WoodingFeb 19, 2007
  10. Andy ParkinsFeb 19, 2007
  11. Jakub NarebskiFeb 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.