Tag: ODR
6 posts
-
Fixing "multiple definition" Linker Errors in C++: ODR, Header Definitions and inline
Why C++ code that compiles fails to link with "multiple definition of" (LNK2005 on MSVC), why header guards do not help, and when to use inline or extern.
-
static Functions in C++: Class Statics vs File-Scope Statics, Linkage and the ODR
How static functions behave in C++ - class static member functions, file-scope static functions and internal linkage, ODR implications, and their effect on memory layout and performance.
-
C++ One Definition Rule : Multiple Definitions and inline
The ODR requires a single definition across the program for variables and functions, with exceptions for inline, templates, and C++17 inline variables.
-
C++ Initialization Order: Static Phases, Cross-TU Globals, Bases and Members
When C++ objects get initialized: zero, constant and dynamic phases, why cross-file global order is unspecified, member vs initializer-list order, and fixes.
-
C++ inline Functions: ODR, Headers, and Compiler Inlining
C++ inline keyword: linkage and ODR for header definitions, not a guarantee of inlining, class members, inline variables (C++17), and virtual functions.
-
C++ Header Files : Declarations, Include Guards, and What
How C++ headers declare APIs while .cpp files define behavior: ODR-safe patterns, include guards, forward declarations, templates, inline functions.