Edit

Share via


Fatal Error C1020

unexpected #endif

Remarks

The #endif directive has no matching #if, #ifdef, or #ifndef directive. Be sure each #endif has a matching directive.

This error can occur if you have conditional preprocessor directives before you include a precompiled header file. The compiler ignores everything in the file before the precompiled header, including any #if, #ifdef, or #ifndef directives. For more information, see /Yu (Use precompiled header).

Examples

The following sample generates C1020:

// C1020.cpp
#endif     // C1020

Possible resolution:

// C1020b.cpp
// compile with: /c
#if 1
#endif