E2141
C++ Builder Programming Language
Severity: MinorWhat Does This Error Mean?
E2141 means the compiler encountered a declaration it could not parse — the structure of the type, variable name, or function signature does not conform to C++ syntax. A typo in a type name, an extra or missing asterisk in a pointer declaration, or an incorrectly placed modifier are the most common causes.
Affected Models
- C++ Builder 10.x (Alexandria)
- C++ Builder 11 (Sydney)
- C++ Builder 12 (Athens)
- RAD Studio 11 and 12
Common Causes
- An unknown type name used in a declaration — the type was never declared or its header is missing
- A C++ keyword used as an identifier: 'class', 'template', 'operator' cannot be variable names
- An invalid combination of modifiers such as 'unsigned float' or 'const const'
- A pointer or reference declarator in the wrong place
- A VCL-specific __property declaration with incorrect syntax
How to Fix It
-
Check the exact spelling of every type name in the declaration. If the type is from a class or library, confirm its header is included.
E2141 and E2268 often appear together when a missing header makes a type name unknown — both errors clear when the header is added.
-
Check for reserved keyword conflicts. In C++, you cannot use class, namespace, template, operator, or other keywords as identifier names.
If you are porting code from C or another language that allowed these names, rename those identifiers.
-
If the error is in a __property declaration, check the RAD Studio documentation for the exact syntax: __property type name = { read=getter, write=setter };
Missing the read or write specifier, or reversing the order, reliably causes E2141 in __property declarations.
Frequently Asked Questions
Is E2141 the same as E2040?
Related but different. E2040 means the declaration was recognised but not properly terminated — usually a missing semicolon. E2141 means the declaration could not be parsed at all — the structure is invalid from the start.
Can compiler upgrades introduce new E2141 errors?
Yes — BCC64 (the 64-bit C++ Builder compiler) is stricter than the older BCC32 compiler. Code that compiled with BCC32 may have E2141 with BCC64 if it relied on non-standard declarations that the stricter compiler now rejects.