Remove C++ class names from binary dll file

后端 未结 2 1021
既然无缘
既然无缘 2021-01-05 03:13

I have a C++ project under Visual Studio 2010 which compiles into a dll. I have several private implementation-specific classes defined in my project, e.g. CMyClass

相关标签:
2条回答
  • 2021-01-05 03:44

    As Tyler Gill mentioned in the comments, this string was left by compiler due to RTTI since CMyClass actually inherits IMyClass and is polymorphic. My problem can be easily solved by disabling RTTI with /GR- switch. Thanks.

    0 讨论(0)
  • 2021-01-05 03:47

    As my guess from a comment appears correct, I'm reposting this as an answer.

    The string of the class name is a result of having RTTI (Runtime Type Information) enabled for the compiled binaries. When RTTI is enabled, the compiler creates objects that store information about the types compiled into the binary, one of whose properties is the name of the type.

    Note that some uses of dynamic_cast and typeid require RTTI, so disabling will cost you those features of C++.

    In order to disable RTTI in Visual Studio, use the /GR- switch (see http://msdn.microsoft.com/en-us/library/we6hfdy0(v=vs.100).aspx, as Mikhail posted.)

    To disable it in GCC, use the -fno-rtti switch.

    0 讨论(0)
提交回复
热议问题