Muokkaa

Jaa


Compiler errors C2001 through C2099

The articles in this section of the documentation explain a subset of the error messages that are generated by the compiler.

Important

The Visual Studio compilers and build tools can report many kinds of errors and warnings. After an error or warning is found, the build tools may make assumptions about code intent and attempt to continue, so that more issues can be reported at the same time. If the tools make the wrong assumption, later errors or warnings may not apply to your project. When you correct issues in your project, always start with the first error or warning that's reported, and rebuild often. One fix may make many subsequent errors go away.

To get help on a particular diagnostic message in Visual Studio, select it in the Output window and press the F1 key. Visual Studio opens the documentation page for that error, if one exists. You can also use the search tool at the top of the page to find articles about specific errors or warnings. Or, browse the list of errors and warnings by tool and type in the table of contents on this page.

Note

Not every Visual Studio error or warning is documented. In many cases, the diagnostic message provides all of the information that's available. If you landed on this page when you used F1 and you think the error or warning message needs additional explanation, let us know. You can use the feedback buttons on this page to raise a documentation issue on GitHub. If you think the error or warning is wrong, or you've found another problem with the toolset, report a product issue on the Developer Community site. You can also send feedback and enter bugs within the IDE. In Visual Studio, go to the menu bar and choose Help > Send Feedback > Report a Problem, or submit a suggestion by using Help > Send Feedback > Send a Suggestion. Some compiler error topics were created that are not emitted by the compiler and now redirect to this page instead.

You may find additional assistance for errors and warnings in Microsoft Learn Q&A forums. Or, search for the error or warning number on the Visual Studio C++ Developer Community site. You can also search Stack Overflow to find solutions.

For links to additional help and community resources, see Visual C++ Help and Community.

Error messages

Error Message
Compiler error C2001 newline in constant
Compiler error C2002 invalid wide-character constant
Compiler error C2003 expected 'defined id'
Compiler error C2004 expected 'defined(id)'
Compiler error C2005 #line expected a line number, found 'token'
Compiler error C2006 'directive': expected a filename, found 'token'
Compiler error C2007 #define syntax
Compiler error C2008 'character': unexpected in macro definition
Compiler error C2009 reuse of macro formal 'identifier'
Compiler error C2010 'character': unexpected in macro formal parameter list
Compiler error C2011 'identifier': 'type' type redefinition
Compiler error C2012 missing name following '<'
Compiler error C2013 missing '>'
Compiler error C2014 preprocessor command must start as first nonwhite space
Compiler error C2015 too many characters in constant
Compiler error C2016 C requires that a struct or union has at least one member
Compiler error C2017 illegal escape sequence
Compiler error C2018 unknown character '0xvalue'
Compiler error C2019 expected preprocessor directive, found 'character'
Compiler error C2020 'member': 'class' member redefinition
Compiler error C2021 expected exponent value, not 'character'
Compiler error C2022 'number': too big for character
Compiler error C2023 'identifier': Alignment (value-1) different from prior declaration (value-2)
Compiler error C2024 'alignas' attribute applies to variables, data members and tag types only
Compiler error C2025 invalid or corrupted binary module interface file: 'filename'
Compiler error C2026 string too big, trailing characters truncated
Compiler error C2027 use of undefined type 'type'
Compiler error C2028 struct/union member must be inside a struct/union
Compiler error C2029 (Obsolete) left of 'token' specifies undefined class/struct/interface 'identifier'
Compiler error C2030 a destructor with 'protected private' accessibility cannot be a member of a class declared 'sealed'
Compiler error C2031 a virtual destructor with 'accessibility' accessibility is not allowed for this type
Compiler error C2032 'identifier': function cannot be member of struct/union 'type'
Compiler error C2033 'identifier': bit field cannot have indirection
Compiler error C2034 'identifier': type of bit field too small for number of bits
Compiler error C2035 a non-virtual destructor with 'accessibility' accessibility is not allowed for this type
Compiler error C2036 'identifier': unknown size
Compiler error C2037 left of 'operator' specifies undefined struct/union 'type'
Compiler error C2038 the std namespace cannot be inline
Compiler error C2039 'identifier1': is not a member of 'identifier2'
Compiler error C2040 'operator': 'identifier1' differs in levels of indirection from 'identifier2'
Compiler error C2041 illegal digit 'character' for base 'number'
Compiler error C2042 signed/unsigned keywords mutually exclusive
Compiler error C2043 illegal break
Compiler error C2044 illegal continue
Compiler error C2045 'identifier': label redefined
Compiler error C2046 illegal case
Compiler error C2047 illegal default
Compiler error C2048 more than one default
Compiler error C2049 'namespace-name': non-inline namespace cannot be reopened as inline
Compiler error C2050 switch expression not integral
Compiler error C2051 case expression not constant
Compiler error C2052 'type': illegal type for case expression
Compiler error C2053 'identifier': wide string mismatch
Compiler error C2054 expected '(' to follow 'identifier'
Compiler error C2055 expected formal parameter list, not a type list
Compiler error C2056 illegal expression
Compiler error C2057 expected constant expression
Compiler error C2058 constant expression is not integral
Compiler error C2059 syntax error: 'token'
Compiler error C2060 syntax error: end of file found
Compiler error C2061 syntax error: identifier 'identifier'
Compiler error C2062 type 'type' unexpected
Compiler error C2063 'identifier': not a function
Compiler error C2064 term does not evaluate to a function taking number arguments
Compiler error C2065 'identifier': undeclared identifier
Compiler error C2066 cast to function type is illegal
Compiler error C2067 cast to array type is illegal
Compiler error C2068 illegal use of overloaded function. Missing argument list?
Compiler error C2069 cast of 'void' term to non-'void'
Compiler error C2070 'type': illegal sizeof operand
Compiler error C2071 'identifier': illegal storage class
Compiler error C2072 'identifier': initialization of a function
Compiler error C2073 (Obsolete) 'identifier': elements of partially initialized array must have a default constructor
Compiler error C2074 'identifier': 'type' initialization requires a brace-enclosed initializer list
Compiler error C2075 'identifier': array initialization requires a brace-enclosed initializer list
Compiler error C2076 a brace-enclosed initializer list cannot be used in a new-expression whose type contains 'type'
Compiler error C2077 non-scalar field initializer 'identifier'
Compiler error C2078 too many initializers
Compiler error C2079 'identifier' uses undefined struct/class/union 'type'
Compiler error C2080 'identifier': the type for 'type' can only be deduced from a single initializer expression
Compiler error C2081 'identifier': name in formal parameter list illegal
Compiler error C2082 redefinition of formal parameter 'identifier'
Compiler error C2083 struct/union comparison illegal
Compiler error C2084 function 'identifier' already has a body
Compiler error C2085 'identifier': not in formal parameter list
Compiler error C2086 'identifier': redefinition
Compiler error C2087 'identifier': missing subscript
Compiler error C2088 'operator': illegal for struct/class/union
Compiler error C2089 'identifier': 'type' too large
Compiler error C2090 function returns array
Compiler error C2091 function returns function
Compiler error C2092 'identifier' array element type cannot be function
Compiler error C2093 'identifier1': cannot be initialized using address of automatic variable 'identifier2'
Compiler error C2094 label 'identifier' was undefined
Compiler error C2095 'function': actual parameter has type 'void': parameter number
Compiler error C2096 'identifier': A data member cannot be initialized with a parenthesized initializer
Compiler error C2097 illegal initialization
Compiler error C2098 unexpected token after data member 'identifier'
Compiler error C2099 initializer is not a constant

See also

C/C++ Compiler and build tools errors and warnings
Compiler errors C2001 - C3999, C7000 - C7999