[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Re: propedit on svn:mime-type

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-03-10 18:29:13 CET

Rafael Garcia-Suarez wrote:

>Branko ÄŒibej <brane@xbc.nu> wrote:
>
>
>>Rafael Garcia-Suarez wrote:
>>
>>
>>>I thought that sizeof("\n") == sizeof(char*).
>>>
>>>
>>No, the type of a string literal is a character array, not a character
>>pointer. So writing "\n" is semantically equivalent to writing
>>
>> (char[]){ '\n', '\0' }
>>
>>if such a thing could be done in C.
>>
>>
>
>Duh, thanks for correcting me. I'm not familiar with the C standards ;
>I wonder if this idiom is reasonably portable across compilers.
>
>
It should be completely portable across all compilers. This isn't
anything new, it's been part of C since K&R times. Of course, it's also
something most C programmers aren't aware of. :-)

The misunderstanding stems from the fact that an array reference is
automaticlly converted to a pointer in function parameters. But sizeof
is not a function, of course -- it's a compile-time operator, so the
function call promotion rules don't apply.

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Mar 10 18:29:54 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.