Re: offsets of fields in a structure
"Jan Smout" <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
On 19/10/2007, Giulio Rossato <[email protected]> wrote: > I want write a function that receives as parameters a start address and > a "description of a structure" and returns the offsets of the fields. > The structure is not known at compile time. The offsets should be > calculated at runtime and the code should be independent of the machine. > How should be written this function? Have a look at the Linux manpage for the "offsetof(type, member)"-macro from stddef.h. It will probably not be exactly what you're looking for, but might be a starting point which gets you going. Jan