Article View: comp.std.c
Article #5963A constant question
From: David Keppel
Date: Fri, 28 Apr 1989 18:52
Date: Fri, 28 Apr 1989 18:52
44 lines
1836 bytes
1836 bytes
This is a `how do I do this in dpANS C' question.
I have a structure that contains pointers to other structures.
struct container_t {
struct adt_t *x;
struct other_stuff x;
};
I have defined some accessor functions, including an initialization
function. The init function takes a pointer to a struct adt_t and
squirrels it away in the struct container_t. The init function does not
change what the adt_t points at. Suppose that my initial attempt at
defining a prototype looks like
extern void
init (struct container_t *dest, struct adt_t squirrel);
Somebody else might get a handle on
the struct adt_t, and change it. Thus,
* `init' does not change the `struct adt_t'.
* `struct container_t' is never used directly to change the `struct
adt_t'.
* The `struct adt_t' may change from time to time.
I am wanting to make the following declaration:
"`init' does not change what it's parameter points at."
The struct container_t does not take a const pointer, so I can't declare
`squirrel' as a const-qualified parameter. I could change the struct
container_t to have a const pointer, but that is incorrect because the
pointed-to storage might change over the lifetime of the container_t.
How should I declare `init'?
Thanks!
;-D on ( A volatile topic ) Pardo
--
pardo@cs.washington.edu
{rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo
Technical Details
Message-ID:
<8038@june.cs.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!pardoShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!pardo From: pardo@june.cs.washington.edu (David Keppel) Newsgroups: comp.std.c Subject: A constant question Message-ID: <8038@june.cs.washington.edu> Date: 28 Apr 89 18:52:54 GMT Reply-To: pardo@uw-june.UUCP (David Keppel) Organization: U of Washington, Computer Science, Seattle Lines: 44