Question
how to get the element count of an array that is part of a struct without defines or const fields?
I have a struct that contains an array.
How can I compute the array element count with standard C, when I do not want to resort to defines or const
fields?
typedef struct TEXTUREBUCKET {
long tpage;
long nVtx;
D3DTLBUMPVERTEX vtx[2048];
} TEXTUREBUCKET;
static inline size_t TextureBucketVertexCount() {
return (sizeof(TEXTUREBUCKET) - offsetof(TEXTUREBUCKET, vtx)) / sizeof(D3DTLBUMPVERTEX); // works as long as vtx is the last member
}