httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject Re: [multi-env] illegal escape sequence
Date Thu, 17 Feb 2005 04:44:17 GMT
On Wed, 16 Feb 2005, Joe Schaefer wrote:

> Joe Schaefer <joe+gmane@sunstarsys.com> writes:
>
> [...]
>
> > Boggle: what happens when you feed that string to this macro:
> >
> >   #define QUOTE_ME(foo) #foo
> >   const char bar[] = QUOTE_ME("rfc=out; Version=1; domain=\"example.com\"");
> >
> > K&R says this about #foo:
>
> The VC6 docs even include a similar example
>
>     <URL:
>         http://msdn.microsoft.com/library/default.asp?
>         url=/library/en-us/vccore98/html/_predir_stringizing_operator.asp
>      >
>
> Staring at the offending code in at.h, I can't
> see what the problem might be here so I'll just
> shut up now. I trust you guys will come up with
> a good solution.

:) Thanks for the pointers, Joe. I'm sure this problem
must have come up in other contexts. For one thing, I found
this suggestion (in a newsgroup) to use:

#define QUOTE_ME_HELPER(foo) #foo
#define QUOTE_ME(foo) QUOTE_ME_HELPER(foo)

But using this or the one you suggested doesn't make a
difference in the following. The following (which is
similar to an example on the msdn site):

int main(void) {
   const char bar[] = QUOTE_ME("domain=\"example.com");
   printf("bar is %s\n", bar);
   return 0;
}

expands to

int main(void) {
   const char bar[] = "\"domain=\\\"example.com\"";
   printf("bar is %s\n", bar);
   return 0;
}

which is OK. However

int main(void) {
   const char bar[] = QUOTE_ME("domain=\"example.com\"");
   printf("bar is %s\n", bar);
   return 0;
}

expands to

int main(void) {
   const char bar[] = "\"domain=\\\"example.com\\"\"";
   printf("bar is %s\n", bar);
   return 0;
}

which explains the "illegal escape sequence" error.
This is with VC++ 6 (with gcc, both the above are fine).

I'll keep looking for solutions ...

-- 
best regards,
randy

Mime
View raw message