简体   繁体   中英

How to quickly find the required header files for a given declaration in Visual Studio / C++ / .NET?

I am trying to compile a Visual Studio / C++ code snippet I have found on the internet containing the function:

Marshal::SizeOf()

When compiling the snippet, I get the error message:

error C2653: 'Marshal' : is not a class or namespace name

so I think I need to include a header file with the definition of this namespace or class, and the SizeOf() function.

When I look up Marshal::SizeOf C++ in Google I find this help page , however on this page there is no information regarding which header file must be included in order to use this function.

Is there a documentation page where one can look up all .NET classes and functions and easily find the C++ header file that must be included in order to use them?

You need to understand what C++/CLI is. It is a proprietary extension to C++ by Microsoft to make the interfacing between native and managed code (ie .Net) easy.

Marshal is not a C++ class, it's a C++/CLI class. As such, there's no header to include. It's #import you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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