typedef Type alias declarations

typedef Type alias declarations

typedef aliases a type to simplify declarations. It creates no new type or safety, obeys scope and declaration syntax, and is not text substitution.

CategoryStorage-class specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

typedef unsigned int uint;

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

count = 2, sum = 7

📚 Related Tutorials

❓ FAQ

QHow does typedef differ from #define for type names?
AThe compiler processes typedef using declaration syntax and scope rules, so it handles composite types such as pointers and arrays correctly. #define performs preprocessor text substitution without type semantics, which can produce different results in complex declarations.
QDoes typedef create a completely new type?
ANo. A typedef name is only an alias for the original type, with the same compatibility and conversion rules. typedef alone therefore cannot provide strong-type isolation for units or similar domains.
QHow are the names after typedef struct used?
AIn typedef struct Point { int x; } Point;, the first struct Point is the tag and the final Point is the type alias; either form can declare objects. An anonymous structure has no tag, so it relies on names introduced by declarations such as the alias.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏