Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C syntax
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Incomplete types=== An incomplete type is a [[#Structures_and_unions|structure or union]] type whose members have not yet been specified, an [[#Arrays|array type]] whose dimension has not yet been specified, or the {{code|void}} type (the {{code|void}} type cannot be completed). Such a type may not be instantiated (its size is not known), nor may its members be accessed (they, too, are unknown); however, the derived pointer type may be used (but not dereferenced). They are often used with pointers, either as forward or external declarations. For instance, code could declare an incomplete type like this: <syntaxhighlight lang=C> struct thing *pt; </syntaxhighlight> This declares {{code|pt}} as a pointer to {{code|struct thing}} ''and'' the incomplete type {{code|struct thing}}. Pointers to data always have the same byte-width regardless of what they point to, so this statement is valid by itself (as long as {{code|pt}} is not dereferenced). The incomplete type can be completed later in the same scope by redeclaring it: <syntaxhighlight lang=C> struct thing { int num; }; /* thing struct type is now completed */ </syntaxhighlight> Incomplete types are used to implement [[Recursion (computer science)|recursive]] structures; the body of the type declaration may be deferred to later in the translation unit: <syntaxhighlight lang=C> typedef struct Bert Bert; typedef struct Wilma Wilma; struct Bert { Wilma *wilma; }; struct Wilma { Bert *bert; }; </syntaxhighlight> Incomplete types are also used for [[data hiding]]; the incomplete type is defined in a [[header file]], and the body only within the relevant source file.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)