使用 g++ 时,我将模板参数作为成员变量传递给 offsetof,并收到以下警告:
invalid access to non-static data member 'SomeClass::t' of NULL object
(perhaps the 'offsetof' macro was used incorrectly)
这是我的用法:
template<typename T> class SomeClass { T t; };
...
offsetof(SomeClass, t); //warning: invalid access to non-static data member 'SomeClass::t' of NULL object, (perhaps the 'offsetof' macro was used incorrectly)
我使用 __builtin_offsetof 得到了同样的错误。有任何想法吗?
谢谢