C: Can anyone recommend a way to write a function that counts the number of fields in a struct? i.e. - sudocode- 'for field in struct' : I want a C function that I can pass a structure to and it will return the number of fields/members within the structure.

At the moment I've found the easiest way is to just make a table and add to the table anytime I add a struct to any of the programs.