Re: Pointer to undeclared structure-type considered ok?

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

 



On 2005-02-02, Eljay Love-Jensen <eljay@xxxxxxxxx> wrote:
>
> Yes, it's ok -- for a lot of operations.  What you are dealing with is a 
> pointer.  A pointer is a fundamental data type.
>

Can "pointer", by itself, be considered a data-type? I always though
that the data-type was actually "pointer to something", which is a
different type from "pointer to something-else"?

> What you cannot do is increment/decrement the pointer, use array access, or 
> access the (undefined, unknown) members, or dereference the pointer in any 
> other fashion[1].

So in my original example, if I added something like "foo.b++", it
would fail.  The error message is:

  error: increment of pointer to unknown structure
  error: arithmetic on pointer to an incomplete type

Which indicates that "struct bar" is indeed a defined, but incomplete,
data-type, and that it is ok to define pointers to incomplete
data-types. Such pointers (i.e. pointer to incomplete data-types) have
"special" semantics (similar but not identical to those of "void"
pointers).

Thanks for helping me sort this out.
/npat


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux