I think the right way to cope with this situation is to make some kind of signature to the structure definition and check it at make time so you can check for modifications.
- first, mark the structures of this type, so you can access to them
easily: something like '_some_tag_' #define'd as nothing in
some header allows you to search for it automatically.
- then, use some kind of development tool to parse the fields, canonicalyze them
and make some kind of hash function as a result.
- register this signature for future compilations and warn the compiling team of a
structure change.
Think, you had better to be overcomplaint than under, so in case of structure modification you'll get at least one indication.
Suppose you have:
struct A { bla bla bla };
and then you modify it to be:
#include <somefile where you have defined macro ___hash_protected___>
/* #define ___hash_protected___ */
...
struct ___hash_protected___ A { bla bla bla };
now, write a program that searches for that tag, computes the signature of structure A and checks it with the value stored in a database file. It must do two things: first compute the hash value of the structure, then compare it with the saved one and warn if they differ. If structure is new, just add the hash value to the database.
I you want to protect it from unauthorized use, just use a cryptographic secure hash function (e.g. SHA256) and protect it with some secret string prepended.
Of course, you'll have to parse at least the structure definition to be able to calculate a valid hash.
but, REMEMBER, you had better to define it in a common include file, than to define it twice. I know there are cases in which a define file has to be distributed to be used at several places, leading to possible different versions of it.