struct accessing

Phil Cornes pc at cs.keele.ac.uk
Mon Jun 26 18:51:03 AEST 1989


>From article <1545 at stl.stc.co.uk>, by dsr at stl.stc.co.uk (David Riches):
> ......... in my dreams, I would like to have a
> statement which says :-
> 
> 	person = fred.$field_name$
> 

This sounds a nice idea but I seriously doubt that you'll find a general
and portable way to do it......

The problem is that your compiler needs to be able to resolve variable
references at compile time..... But the contents of your variable $field_name$
may well not be known until run time.

This means that the best you can do is to write some sort of interpreter
which can scan the variable and sort out its meaning at run time instead of
at compile time.... And it didn't sound like this is what you were after
(indeed it's what you've already got).



More information about the Comp.lang.c mailing list