This documentation is archived and is not being maintained.

Compiler Error C2180

Error Message

controlling expression has type 'type'

The controlling expression in an if, while, for, or do statement is a function with return type void or an expression cast to void.

The following sample generates C2180:

// C2180.c
void test() {}
int test2() {
   return 0;
}

int main() {
   if (test()) ;   // C2180
   if (test2()) ;   // OK
}

C2180 can also be generated when nullptr is used as the expression in a control statement.

The following sample generates C2180:

// C2180b.cpp
// compile with: /clr
int main() {
   int i = 0;
   if (nullptr) {}   // C2180
   if (i == 0) {}   // OK
}
Show: