RTL_FIELD_SIZE



winnt.h


//

// Calculate the size of a field in a structure of type type, without

// knowing or stating the type of the field.

//

#define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))



- Microsoft Windows Macro

- 구조체 안에 있는 특정 멤버에 대한 사이즈를 얻어올 때 사용하면 되겠다.

- 구조체 안에 있는 멤버의 타입을 몰라도 매크로 사용에 문제가 없다.

- Linux 에서는 FIELD_SIZE(Type, Field) 사용



ex)

struct A
{
    char arr[64];
};

size_t nSize = RTL_FIELD_SIZE(A, arr);


cf) C++ Numbers and Operators - MSDN

cf) sizeof a struct member - stackoverflow


Posted by six605
,