नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'return_type/args' : cannot call a function with __clrcall calling convention from native code
Remarks
A function that is marked with the __clrcall calling convention cannot be called from native (unmanaged) code.
return_type/args is either the name of the function or the type of the __clrcall function you are trying to call. A type is used when you're calling through a function-pointer.
To call a managed function from a native context, you can add a "wrapper" function that will call the __clrcall function. Or, you can use the CLR marshalling mechanism; see How to: Marshal Function Pointers Using PInvoke for more information.
Example
The following example generates C3642:
// C3642.cpp
// compile with: /clr
using namespace System;
struct S {
void Test(String ^ s) { // CLR type in signature, implicitly __clrcall
Console::WriteLine(s);
}
void Test2(char * s) {
Test(gcnew String(s));
}
};
#pragma unmanaged
int main() {
S s;
s.Test("abc"); // C3642
s.Test2("abc"); // OK
}