root-framework - ROOT 中的 ClassImp 预处理器宏 - 真的需要吗?

标签 root-framework

我真的必须使用 ClassImp宏有利于ROOT中的自动字典和流光生成?一些在线教程和示例提到了它,但我注意到只需添加 ClassDef(MyClass, <ver>)宏到MyClass.h并用 rootcint/rootcling 处理它已经生成了大部分此类代码。

我确实看过Rtypes.h这些宏是在哪里定义的,但遵循预处理器宏相互调用并不容易,因此,如果专家能够确认 ClassImp 的作用,那就太好了。我对 ROOT >= 5.34 的最新版本特别感兴趣

最佳答案

这是我在 roottalk 邮件列表上得到的答案,确认 ClassImp 的使用基本上已经过时了。

ClassImp is used to register in the TClass the name of the source file for the class. This was used in particular by THtml (which has now been deprecated in favor of Doxygen). So unless you code/framework needs to know the name of the source files, it is no longer necessary to have ClassImp.

ClassDef is necessary for class inheriting from TObject (or from any classes that has a ClassDef). In the other cases, it provide accelerator that makes the I/O slightly faster (and thus is technically not compulsory in this case). It also assign a version number to the schema layout which simplifies writing schema evolution rules (on the other hand, there is other alternative to assign a version number to the schema layout).

关于root-framework - ROOT 中的 ClassImp 预处理器宏 - 真的需要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38438648/

相关文章:

c++ - 在 ROOT 中迭代绘制 TEllipse

c++ - 如何从用户输入修改 C++ 代码

c++ - 将字符串变量从 bash 脚本传递到根宏

c++ - 如何在ROOT下编译多个文件

root-framework - 在 CERN ROOT 程序中向 TGraph 添加第二个 x 轴

c++ - 使用 g++ 编译包含根库的 c++

c++ - 对 `TVersionCheck::TVersionCheck(int) 的 undefined reference

cmake - Clion 或 cmake 看不到环境变量

ROOT TTree 中的 Python 字符串数组

c++ - 如何在 C++17 中使用 CERN Root?