Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C2171

Error Message

'operator' : illegal on operands of type 'type'

A unary operator is used with an invalid operand type.


The following sample generates C2171.

// C2171.cpp
int main() {
   double d, d1;
   d = ~d1;   // C2171

   // OK
   int d2 = 0, d3 = 0;
   d2 = ~d3;

The following sample generates C2171.

// C2171_b.cpp
// compile with: /c
class A {
   A() { STF( &A::D ); }

   void D() {}
   void DTF() {
      (*TF)();   // C2171
      (this->*TF)();   // OK

   void STF(void (A::*fnc)()) {
      TF = fnc;

   void (A::*TF)();

Community Additions

© 2015 Microsoft