简体   繁体   English

如何在.NET下的C / C ++中确定运行时的方法参数类型?

[英]How to determine method parameter types during runtime in C/C++ under .NET?

in C# it is possible by using reflection to determine parameter types of some method as well as class members (method, properies..). 在C#中,可以通过使用反射来确定某些方法的参数类型以及类成员(方法,属性..)。 I suppose that this is possible because of IL and .NET technology, right ? 我想这可能是因为IL和.NET技术对吧? If so is it possible to use reflection or some similar technique for C/C++ writen under Visual studio 2005/2008/2010 .NET ? 如果可以的话,是否可以对Visual Studio 2005/2008/2010 .NET下编写的C / C ++使用反射或类似技术?

br, Milan. br,米兰。

It is possible because of metadata in an assembly, put there by the compiler. 可能由于程序集中存在汇编程序中的元数据。 And an extensive API that allows reading that data. 以及广泛的API,允许读取该数据。 And the essential Object.GetType() method and typeof keyword. 以及基本的Object.GetType()方法和typeof关键字。

None of which is available in a C or C++ compiler. C或C ++编译器均不提供这些功能。 You could hack around this a bit with RTTI and reading the debug symbol file. 您可以使用RTTI来解决这个问题,并读取调试符号文件。 I doubt it's worth the effort. 我怀疑是否值得付出努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM