On this page
extern
Prev: static | Up: builtins | Next: inline
Rel: static, Build Pipeline & Linking
Ref: cppreference — extern
Tags: #public #prog #c #builtins #tier/standard
Availability
Built-in (Storage-Class Specifier) — requires no #include header.
Syntax & Overview
extern T symbol;
Declares a variable or function with external linkage defined in another translation unit without allocating storage.
Notes & Pitfalls
- Declares external linkage without defining storage: Put
extern int g_count;in a header andint g_count = 0;in exactly one.cfile to avoid duplicate-symbol linker errors.
Example
// In header.h: extern int g_retries;
// In config.c: int g_retries = 3;
Linked from
Related notes
- tuts/c/builtins/inline Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/static Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins Linked here; links to this page; shared tags: #builtins, #c, #prog
- tuts/c/compilation_and_internals/build_pipeline_and_linking Linked here; shared tags: #c, #prog
- tuts/c/builtins/__FILE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__func__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__LINE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__STDC_VERSION__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Alignof shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Atomic shared tags: #builtins, #c, #prog, #tier