CompuServe Messages

#Strings in C

    25-Nov-94 18:44:53
Sb: #44221-#Strings in C
Fm: Shraddhan 70374,754
To: Peter Wade 100265,2740
Peter, Thanks for showing me how to create arrays of structures. I now have a little problem that has had me baffled for the last three hours, and I have discovered that it is to do with the use of EXTERN. I'm having some difficulty referring in one file to an array defined in another file. One file contains: struct Atom { char *_Name; APTR atom_Value; APTR atom_Next; }; struct Atom Object[] = { { "alpha" }, { "beta" }, { "gamma" }, }; /* …… to here */ The second file contiains: #define Value_Beta Object[1].atom_Value as a convenient way of referring to the value pointer of an array item. (I woould really like to be able to refer by name to something like 30 out of the 2500 or so memory locations used by the array.) However, when I try to use Value_Beta, I keep getting errors which imply that the structures in the array elements are not defined. I have tried the following two lines to no avail in the second file: extern struct Atom Object[]; extern Object[]; The code seems to compile with no problem if the two files are combined. Why won't the compiler (DICE) recognise that the array referred to in one file is defined in the other file? Regards, Shraddhan (via AP from Hertfordshire, England)