"Greg Lutz" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I've been watching the responses on this thread with some amazement,
> because so far, no one has noticed the essential problem: it's a compiler
> bug all right, for not rejecting the code out of hand!
>
> It's the first statement in the function that's wrong. Some choices for
> statements that would be *right* are:
>
> static const char threeChars[] = "123";
>
> static const char threeChars[] = {'1', '2', '3'};
>
> static const char *threeChars[] = {"123"};
>
> The first and third are misnomers: the first generates a four-member array
> of characters ('1', '2', '3', and '\0'), and the third generates a
> one-member array of pointers to character arrays (strings). The second
> generates what the variable name promises.
>
> I have trouble guessing what the original code generates. Evidently
> something pretty weird.
Gregg's original code: static const char threeChars[] = {"123"};
Code from your reply: static const char threeChars[] = "123";
Gregg's code may not be "perfect" C syntax, but it generates the same exact
code. The format of Gregg's definition for threeChars[] is obviously NOT the
essential problem.
"Roger Stringer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> >Subject: Compiler bug? Index error switching from static const "char" to
> >"Char"!
> >From: "Gregg Woodcock" <[EMAIL PROTECTED]>
> >Date: Mon, 8 Dec 2003 10:53:42 -0600
> >
> >I am trying to be a GoodCoder (TM)
>
> Seems a little strong to describe yourself as a
> 'good coder' (sic) if you don't know the difference between
> between a char and a pointer.
>
> > static const Char threeChars[] = {"123"};
> >
> > ((threeChars[0] != NULL)
>
> This condition should be written as
> (threeChars[0] != '\0')
>
> Hint:
> Before complaining of a compiler bug, first remove the errors from your
code!
Did we wake up on the wrong side of bed? Again Gregg's code may not be
perfect syntax, but '\0' and NULL work out to the same value, so the
generated code is exactly the same. Do you always respond to people asking
for help by criticizing their code? Was your response even necessary?
Hint for you Roger: Next time think before posting and let's continue to
keep this a helpful forum.
-Robert
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/