如何将解析令牌的C宏转换为D?

如何将解析令牌的C宏转换为D?,d,D,如何将解析令牌的C宏转换为D # define _SIZEOF(x) sz_##x # define SIZEOF(x) _SIZEOF(x) # define NEXTPTR(p,t) (((char *) p) + SIZEOF(t)) 谢谢哇。那是一个骇客 铸造(void*)p+sz_[哪个],我会说?只需手动展开它。哇。那是一个骇客 template SIZEOF(T) { static if (is(T == char)) enum SIZEOF = sz_char;

如何将解析令牌的C宏转换为D

# define _SIZEOF(x) sz_##x
# define SIZEOF(x) _SIZEOF(x)
# define NEXTPTR(p,t)  (((char *) p) + SIZEOF(t))
谢谢

哇。那是一个骇客

铸造(void*)p+sz_[哪个]
,我会说?只需手动展开它。

哇。那是一个骇客

template SIZEOF(T) {
  static if (is(T == char))
    enum SIZEOF = sz_char;
  else static if (is(T == ...))
    ...
}

T* NEXTPTR(T)(p) {
  return (((char *) p) + SIZEOF!t)
}

铸造(void*)p+sz_[哪个]
,我会说?只需手动将其展开。

这不是与
相同吗定义NEXTPTR(p,t)((char*)((t*)p)+1))
(如果
sz
前缀与
sizeof
相同,
sz
前缀的使用让我觉得它与
sizeof
不同:(如果
sz
前缀与
sizeof
相同,
sz
前缀的使用让我觉得它与
sizeof
不同:(使用示例:BYTE eventdata[sizeof(xEvent)];xEvent它是struct xEvent{}使用示例:BYTE eventdata[SIZEOF(xEvent)];xEvent它是struct xEvent{}
template SIZEOF(T) {
  static if (is(T == char))
    enum SIZEOF = sz_char;
  else static if (is(T == ...))
    ...
}

T* NEXTPTR(T)(p) {
  return (((char *) p) + SIZEOF!t)
}