Bifalgorithm post · Computer science one · Nested Structures
How should structure names and member variables be declared in C?
How should structure names and member variables be declared in C? (Computer science one · Nested Structures) — "typedef struct Student { 2 ... 3 } Student; Whi…
Ideas in this flowchart
- C structure naming and internal member-variable conventions
- The typedef declaration places the Student identifier in both the global space and the structure space.
- The declaration style depends on several factors; for simplicity, the first style is used here.
- Older conventions may use lowercase underscore names for structures.
- POSIX systems use names ending in _t to indicate a structure type.
- Such naming conventions should be avoided to prevent conflicts.
- C does not provide a mechanism for protecting data.
- Libraries and code bases may begin member variables with underscores to mark them as internal.
- _someVariable and __anotherVariable can indicate variables that should not be accessed or modified.
- C still allows these variables to be accessed and modified.
- Tampering may violate library assumptions and expectations, leading to undefined behavior.