#: 7185 S3/Languages
04-Oct-90 21:23:22
Sb: #7182-#c_problem
Fm: James Jones 76257,562
To: ANDY THIBODEAU 76636,2300 (X)
OK--your compiler manual is *not* wrong. Neither is Pete.
This isn't anything like "light is a wave *and* a particle" or even "Certs is a
candy mint and a breath mint." Here's the deal:
The typical compiler manual shows you what would be the first part of a formal
declaration of the function (or what it would be if it were a function, since
sometimes it's really a macro). What that shows you is the type of the actual
parameter you should pass.
Now, in your invocation of the function, you passed it a variable that indeed
has the correct type, i.e. pointer to struct sgtbuf. However, the *value* that
you passed is not correct, because it is not in fact the address of a struct
sgtbuf.
Analogy: you call (invoke :-) a sign painter, who comes to your house and asks
where the sign to be painted is, i.e. he wants a pointer to the sign you want
painted. What you did in your invocation is the moral equivalent of pointing
into empty space, that is it was a response of the correct type (pointer to a
sign) but with an invalid value (because there was in fact no sign where you
pointed).
What Pete suggests is analogous to the following: before you call the painter,
you build an (unpainted) sign. (In C, you'd declare a struct sgtbuf, "struct
sgtbuf buf;".) When you call the painter, and he asks you to point to the sign
to be painted, point at the sign you built. (In C, pass getime() the address of
the structure you declared: "getime(&buf);".)
This is admittedly a dumb analogy, but it's the best I could do on shorot --er,
short--notice, while the CIS $$$ meter is ticking. I hope it helps to
show what's going on.
There is 1 Reply.
|