Compiler Error C2217
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2217.
attribute1' requires 'attribute2'
The first function attribute requires the second attribute.
To fix by checking the following possible causes
Interrupt (
__interrupt) function declared asnear. Interrupt functions must befar.Interrupt function declared with
__stdcall, or__fastcall. Interrupt functions must use C calling conventions.
C2217 can also occur if you attempt to bind a delegate to a CLR function that takes a variable number of arguments. If the function also has e param array overload, use that instead. The following sample generates C2217.
// C2217.cpp
// compile with: /clr
using namespace System;
delegate void MyDel(String^, Object^, Object^, ...); // C2217
delegate void MyDel2(String ^, array<Object ^> ^); // OK
int main() {
MyDel2^ wl = gcnew MyDel2(Console::WriteLine);
array<Object ^ > ^ x = gcnew array<Object ^>(2);
x[0] = safe_cast<Object^>(0);
x[1] = safe_cast<Object^>(1);
// wl("{0}, {1}", 0, 1);
wl("{0}, {1}", x);
}
Show: