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.
Example
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);
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for