Re: char (*ptr)[]

From: Old Wolf (oldwolf_at_inspire.net.nz)
Date: 02/24/05


Date: 23 Feb 2005 18:25:50 -0800

Walter Roberson wrote:
> Old Wolf <oldwolf@inspire.net.nz> wrote:
> >Walter Roberson wrote:
> >> Rafal Dabrowa <rdsbrows@poczts.onet.pl> wrote:
> >> > void f( char (*ptr)[] );
>
> >> In the first, there is a hint to the reader that what is pointed
> >> to is a constant pointer
>
> >Where? I don't see 'const' anywhere.
>
> I said a hint to the reader, not a hint to the compiler.
>
> array[subscript] where array is a variable (rather than an
> expression) implies that the array location is a constant
> far as that block of code is concerneid, so when someone
> takes the trouble to write the extra () and []

You speak as if the () and [] don't make any difference.

char (*ptr)[] is a completely different type to char *ptr[],
and it isn't possible to write it without the [] .

> then they are usually trying to emphasize that what ptr points
> to is a value that is not going to change.

Never heard that one before. Anyway, as you might have gathered
by now, char (*ptr)[] is quite a different kettle of fish to
your average foo[bar] .



Relevant Pages

  • Re: Which PIC18 C Compiler?
    ... All functions that *might* be invoked by a pointer are identifiable. ... > treated as reenterant (or flagged by the compiler as being too complex) ... Of course, if the programmer supplies a hint that is wrong, all bets ...
    (comp.arch.embedded)
  • Re: declarations summary
    ... If you're keen to hack on the compiler to take advantage of such ... such an "other hint") was SO crucial, to where it doesn't matter in the ... Used to be that C compilers didn't do register allocation with any skill ... difficulty in learning the language that has absolutely no reason to ...
    (comp.lang.python)
  • Re: 406 Not Acceptable (was Re: "--All You Zombies--" title)
    ... :: world's fairly simple idea that it's a hint that "it's in ROM and you ... along with limits to what the compiler is required to diagnose ... (which turn into the "undefined behavior" thing; ... it is never required that the compiler diagnose ...
    (rec.arts.sf.written)
  • General remarks on restrict (was: restrict vs. threads)
    ... it might be a hint that stdio.h on my Solaris box doesn't ... an optimizing hint that the programmer gives the compiler, ... having a way to tell the compiler about some of the constraints on ...
    (comp.std.c)
  • Re: active record
    ... Hope this time caps and line breaks are fine. ... Even then also it SUCKS just IGNORE NO NEED TO REPLY. ... >>which further implies that you are but an arrogant bustardazoid, ... I am allowed to write "Hint" because I have been using Usenet for 15 years. ...
    (comp.lang.java.programmer)