Re: [PATCH] static const field reassigned in pop3.c



On 02/20/2005 09:28:55 PM, Kacper Wysocki wrote:
[ snip ]
I thought const fields indicated that the field wouldn't be reassinged? Or do you use 'const' here to mean that it's a pointer to a character constant?

I have the hardest time keeping that straight--yes, the latter: const char *service is a pointer to a string that must not be changed; the compiler won't allow assignment to *service (or service[n]). But assignment to service is fine.

But if you use

typedef char *char_p;

then const char_p service declares a variable that you can't assign to! That is, you can initialize it, but never change it. There's some binding here that's hard to figure out... I don't know how you'd declare such a service without the typedef. It's as if the first version is (const char) *service, and the second is const (char *) service--but I believe these parenthesized declarations are not the correct syntax.

0K
--
No need to cc: me, I'm on the list.

OK

Best,

Peter




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]