當使用G ++我通過一個模板參數作爲成員變量offsetof,我得到以下警告:克++不會讓我通過一個模板參數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得到相同的錯誤。有任何想法嗎?
感謝