Muokkaa

Jaa


Compiler errors C2100 through C2199

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 C2100 illegal indirection
Compiler error C2101 '&' on constant
Compiler error C2102 '&' requires l-value
Compiler error C2103 '&' on register variable
Compiler error C2104 '&' on bit field ignored
Compiler error C2105 'operator' needs l-value
Compiler error C2106 'operator': left operand must be l-value
Compiler error C2107 illegal index, indirection not allowed
Compiler error C2108 subscript is not of integral type
Compiler error C2109 subscript requires array or pointer type
Compiler error C2110 '+': cannot add two pointers
Compiler error C2111 '+': pointer addition requires integral operand
Compiler error C2112 '-': pointer subtraction requires integral or pointer operand
Compiler error C2113 '-': pointer can only be subtracted from another pointer
Compiler error C2114 'operator': pointer on left; needs integral value on right
Compiler error C2115 'operator': incompatible types
Compiler error C2116 function parameter lists differed
Compiler error C2117 'identifier': array bounds overflow
Compiler error C2118 negative subscript
Compiler error C2119 'identifier': the type for 'type' cannot be deduced from an empty initializer
Compiler error C2120 'void' illegal with all types
Compiler error C2121 '#': invalid character: possibly the result of a macro expansion
Compiler error C2122 'identifier': prototype parameter in name list illegal
Compiler error C2123 'identifier': alias templates cannot be explicitly or partially specialized
Compiler error C2124 divide or mod by zero
Compiler error C2125 'constexpr' is incompatible with 'token'
Compiler error C2126 'identifier' cannot be declared with 'constexpr' specifier
Compiler error C2127 'identifier': illegal initialization of 'constexpr' entity with a non-constant expression
Compiler error C2128 'function': alloc_text/same_seg applicable only to functions with C linkage
Compiler error C2129 static function 'identifier' declared but not defined
Compiler error C2130 #line expected a string containing the filename, found 'token'
Compiler error C2131 expression did not evaluate to a constant
Compiler error C2132 syntax error: unexpected identifier
Compiler error C2133 'identifier': unknown size
Compiler error C2134 'function': call does not result in a constant expression
Compiler error C2135 'operator': illegal bit field operation
Compiler error C2136 authoring API contract not allowed
Compiler error C2137 empty character constant
Compiler error C2138 illegal to define an enumeration without any members
Compiler error C2139 'class': an undefined class is not allowed as an argument to compiler intrinsic type trait 'trait'
Compiler error C2140 'type': a type that is dependent on a generic type parameter is not allowed as an argument to compiler intrinsic type trait 'trait'
Compiler error C2141 array size overflow
Compiler error C2142 function declarations differ, variable parameters specified only in one of them
Compiler error C2143 syntax error: missing 'token1' before 'token2'
Compiler error C2144 syntax error: 'type' should be preceded by 'token2'
Compiler error C2145 syntax error: missing 'token' before identifier
Compiler error C2146 syntax error: missing 'token' before identifier 'identifier'
Compiler error C2147 syntax error: 'token' is a new keyword
Compiler error C2148 total size of array must not exceed 0xvalue bytes
Compiler error C2149 'identifier': named bit field cannot have zero width
Compiler error C2150 'identifier': bit field must have type 'int', 'signed int', or 'unsigned int'
Compiler error C2151 more than one language attribute
Compiler error C2152 'identifier': pointers to functions with different attributes
Compiler error C2153 integer literals must have at least one digit
Compiler error C2154 'type': only enumeration type is allowed as an argument to compiler intrinsic type trait 'trait'
Compiler error C2155 '?': invalid left operand, expected arithmetic or pointer type
Compiler error C2156 pragma must be outside function
Compiler error C2157 'identifier': must be declared before use in pragma list
Compiler error C2158 'type': #pragma make_public directive is currently supported for native non-template types only
Compiler error C2159 more than one storage class specified
Compiler error C2160 '##' cannot occur at the beginning of a macro definition
Compiler error C2161 '##' cannot occur at the end of a macro definition
Compiler error C2162 expected macro formal parameter
Compiler error C2163 'function': not available as an intrinsic function
Compiler error C2164 'function': intrinsic function not declared
Compiler error C2165 'modifier': cannot modify pointers to data
Compiler error C2166 l-value specifies const object
Compiler error C2167 'function': too many actual parameters for intrinsic function
Compiler error C2168 'function': too few actual parameters for intrinsic function
Compiler error C2169 'function': intrinsic function, cannot be defined
Compiler error C2170 'identifier': not declared as a function, cannot be intrinsic
Compiler error C2171 'operator': illegal on operands of type 'type'
Compiler error C2172 'function': actual parameter is not a pointer: parameter number
Compiler error C2173 'function': actual parameter is not a pointer: parameter number, parameter list number
Compiler error C2174 'function': actual parameter has type 'void': parameter number, parameter list number
Compiler error C2175 'locale': invalid locale
Compiler error C2176 a return statement cannot appear in the handler of a function-try-block associated with a constructor
Compiler error C2177 constant too big
Compiler error C2178 'identifier' cannot be declared with 'specifier' specifier
Compiler error C2179 'type': an attribute argument cannot use type parameters
Compiler error C2180 controlling expression has type 'type'
Compiler error C2181 illegal else without matching if
Compiler error C2182 'identifier': illegal use of type 'void'
Compiler error C2183 syntax error: translation unit is empty
Compiler error C2184 'type': illegal type for __except expression
Compiler error C2185 'identifier': illegal based allocation
Compiler error C2186 'operator': illegal operand of type 'void'
Compiler error C2187 syntax error: 'token' was unexpected here
Compiler error C2188 'number': too big for wide character
Compiler error C2189 'alignas' attribute cannot be applied to a bit-field, a function parameter, an exception declaration, or a variable declared with 'register' storage class
Compiler error C2190 first parameter list longer than second
Compiler error C2191 second parameter list longer than first
Compiler error C2192 parameter 'number' declaration different
Compiler error C2193 'identifier': already in a segment
Compiler error C2194 'identifier': is a text segment
Compiler error C2195 'identifier': is a data segment
Compiler error C2196 case value 'value' already used
Compiler error C2197 'function': too many arguments for call
Compiler error C2198 'function': too few arguments for call
Compiler error C2199 syntax error: found 'identifier (' at global scope (was a declaration intended?)

See also

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