C/C++ Declaration Explainer & Builder
Read common C and C++ declarators in plain English or construct a correct variable, pointer, array, function, or function-pointer declaration from structured fields—all locally in your browser.
C/C++ Declaration Explainer & Builder workspace
Focused coverage: named objects, pointers, arrays, functions, function pointers, and pointers to arrays. This is an explainer, not a full compiler parser.
C/C++ Declaration Explainer & Builder example
Parentheses make compare a pointer first; the following parameter list then makes the pointed-to object a function.
Example input
int (*compare)(const void *, const void *);Expected output
compare is a pointer to a function accepting const void *, const void * and returning integer.
Identifier: compare
Base type: int
Layers: pointer → functionHow to use C/C++ Declaration Explainer & Builder
- 1
Choose Explain and paste one declaration without an initializer or function body.
- 2
Select Explain declaration or press Ctrl/Cmd + Enter.
- 3
Read the identifier, base type, outward layer order, and complete English interpretation.
- 4
To create a declaration, switch to Build and provide the base type, identifier, and desired shape.
- 5
Enter an array size or parameter list when that shape needs one, build the declaration, and copy the reviewed output.
What this tool does
Explain mode reads one named C or C++ declaration and works outward from the identifier, following the same precedence that makes parentheses, array suffixes, function suffixes, and pointer operators significant. The result separates the declared name, base type, and each derived layer before presenting a plain-English sentence.
Build mode takes a base type, identifier, declarator shape, and any required array or parameter information. It generates a declaration with the parentheses needed for function pointers and can immediately explain the generated result so you can verify what it says.
The parser deliberately targets the declarator forms developers encounter most often rather than claiming to implement every production in the C and C++ grammars. Unsupported constructs produce an explicit message instead of a confident but misleading explanation.
Features and options
- Plain-English declarator readings
- Identifier and base-type extraction
- Ordered pointer, array, and function layers
- Variable and pointer builder
- Array builder with optional symbolic size
- Function and function-pointer builder
- Optional const-qualified base type
- Inline errors for unsupported or malformed input
- Copy and download for generated declarations
Technical information
C and C++ declarators combine a declaration-specifier sequence with operators around the declared identifier. Postfix [] and () bind at the direct-declarator level, while parentheses change grouping; that is why int *items[4] is an array of pointers but int (*items)[4] is a pointer to an array.
The explainer recognizes one named object, pointer, array, function, function pointer, array of function pointers, or pointer-to-array in a focused grammar. It strips one trailing semicolon, but rejects initializers, bodies, templates, constraints, and decltype because those require a broader language parser.
Parameter text and user-defined base types are reported as written. The tool does not resolve typedefs, namespaces, platform ABI rules, overloads, or whether a declared type is semantically legal in a particular language version.
Common use cases
- Understanding callback typedef-style syntax
- Reviewing arrays of pointers and pointers to arrays
- Teaching the clockwise or spiral declarator rule
- Building a function-pointer declaration
- Checking parentheses before editing a header
- Explaining unfamiliar C API signatures
Limitations
- This is not a complete C or C++ compiler front end.
- It accepts one named declaration at a time and does not parse comma-separated declarator lists.
- Initializers, attributes, references, pointers to members, templates, trailing return types, bit-fields, and function bodies are outside the focused grammar.
- Parameter lists are displayed but not recursively type-checked.
- A successful explanation does not prove that the declaration is valid for every compiler, standard version, or ABI.
Related tools
References & Sources
Defines declarator syntax and explains how pointer, array, and function operators modify the declared type.
Verified 2026-08-13 ↗eel.is · SpecificationC++ Draft — Type Names and Declarator ExamplesProvides normative declarator examples including arrays of pointers, pointers to arrays, functions, and function pointers.
Verified 2026-08-13 ↗eel.is · SpecificationC++ Draft — PointersDefines pointer declarators and clarifies where cv-qualifiers apply.
Verified 2026-08-13 ↗open-std.org · Standards BodyC23 Working Draft N3096Working draft of the C language specification used to cross-check C declarator terminology and grammar.
Verified 2026-08-13 ↗C/C++ Declaration Explainer & Builder FAQ
Why are C and C++ declarations read from the identifier outward?
The operators closest to the declared identifier determine the first derived layer. Array and function suffixes bind differently from pointer prefixes, and parentheses can change that grouping.
What is the difference between int *values[10] and int (*values)[10]?
The first declares an array of ten pointers to int. The second declares one pointer to an array of ten int values; the parentheses move the pointer layer closer to values.
Can it explain function pointers?
Yes, including forms such as int (*callback)(double). It reports the pointer layer, parameter text, and return base type.
Does it support typedefs and user-defined types?
A user-defined base type can be displayed as written, but the tool does not look up typedef definitions or resolve namespaces and templates.
Why was my declaration rejected?
The focused parser intentionally rejects multi-declarator statements, initializers, bodies, templates, attributes, references, member pointers, constraints, and other constructs that need a full compiler parser.
Is a generated declaration guaranteed to compile?
The builder generates the supported declarator shape, but only your target compiler can validate the complete type names, parameter declarations, language version, and surrounding program.