且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C宏获取typeof参数

更新时间:2023-12-01 08:55:16

typeof 不是宏,它是语言构造,是由编译器而不是预处理器扩展的.由于预处理是在编译之前进行的,因此宏无法访问 typeof 结果.

typeof isn't macro, it is language construction and it is expanded by compiler, not preprocessor. Since preprocessing goes before compilation, macro can't access typeof result.

您的 delete(p)扩展为:(destroyObject(&(typeof(* p)_info),p)).(您可以通过 -E gcc标志看到它)

Your delete(p) is expanded to: (destroyObject(&(typeof(*p)_info), p)). (You can see it by -E gcc flag)