Declaring externally-defined structures
Kirk Bertsche
bertsche at llnl.gov
Thu May 30 09:35:28 AEST 1991
I am new to C programming, and am having some difficulty trying to declare
a variable in a function, which is part of a structure defined in my
top-level routine. I have a main program with about 6 functions, which is
to be patched into an existing software system.
My top-level routine (containing a function and my main program) has, near
the top:
struct lb_link tuneflag, tuneerror;
In the main program I have;
if (!rsv_1name("STUNE.FLG", LB_INPUT, &tuneflag)) high_water(98);
if (!rsv_1name("STUNE.ERR", LB_INPUT, &tuneerror)) high_water(98);
(This uses a bunch of routines defined by the existing software to resolve
names and assign addresses and structures.)
When I want to read the state of these variables, I do something like:
while (*tuneflag.pval) {
This all seems to work fine in my top-level routine.
The problem I'm having is when I want to check this flag in another
function. I've tried all of the following near the beginning of the
second function (on line 22, to be precise):
extern struct lb_link tuneflag,tuneerror;
struct lb_link tuneflag,tuneerror;
extern struct tuneflag,tuneerror;
extern float *tuneflag.pval,*tuneerror.pval;
But none of these seem to work. When I try to check the flag, by looking
at *tuneflag.pval (on line 40), I get compiler error messages:
line 40: pval undefined
line 40: member of structure or union required
line 40: incorrect indirection
For some of the attempts above, I also get errors like:
line 22: unknown size
line 22: unknown size
Any ideas? How can I tell this function that the variable in question is
defined elsewhere?
Please respond by e-mail, (bertsche at llnl.gov), if anyone has any ideas.
Thanks!
-----------------------------------------------------------------------------
Kirk Bertsche (bertsche at llnl.gov) (415) 422-8139
Lawrence Livermore National Laboratory
P.O. Box 808 L-397, Livermore, CA 94551-0808
More information about the Comp.lang.c
mailing list