mikec@ux1.lbl.gov (Mike Chin) (08/18/89)
Given: an char[] and a "tag" that identifies it as being a structure defined in a typedef. The structures consist of char, ints, floats and arrays thereof; no pointers or other structures are contained. Problem: create a function that formats each element for display, and a function that allows any element's offset into the structure to be determined. In other words: StructDump (char StructureArea[SIZEOFBIGGEST], char StrucTag); and StructAlter (char StructureArea[SIZEOFBIGGEST], char StrucTag, int WhichElement, int *Offset); Why: This is part of the instrumentation system that uses remote single-board computers networked back to a PS/2 running Presentation Manager. Both ends of this system are coded in C, and indeed use the exact same .h file that typedefs ~25 structures, each with 25-30 elements. I *know* that fiddling with the addresses of structure elements is squirrly, but "packing" options on the compilers allow this. I *know* I could hard-code this, but a method that depends only on the current contents of the .h file would be neater. I'm thinking of creating some sort of intermediate file from the .h, but figuring out the offsets w/o referencing each of the structures' elements in code has me stumped. Would lex/yacc be of help? Mike Chin Lawrence Berkeley Labs MJChin@lbl.gov