Hasty Briefsbeta

Bilingual

A bunch of stuff I used to not know about K&R C

7 hours ago
  • #pre-ANSI C
  • #C programming
  • #K&R C
  • C's grammar is context-sensitive due to single-pass compiler design and lack of function prototype scope in K&R C.
  • The 'void' keyword and type qualifiers like 'const' were ANSI inventions; pre-ANSI C used 'int' for returns and had mutable string literals.
  • Pre-ANSI C lacked 'signed' specifier, limited type combinations (e.g., no 'unsigned char'), and used 'long float' as synonym for 'double'.
  • Integer promotion rules diverged: 'unsigned preserving' vs. 'value preserving' (standardized), with no 'U' suffix and unsigned constants having 'int' type if fitting.
  • Octal constants allowed digits 8 and 9; missing escape sequences like '\a', and '\"' was effectively valid via backslash dropping.
  • Preprocessor lacked '##', '#', '#elif', 'defined' operator, and predefined macros; line continuations restricted to certain contexts.
  • Function declarators lacked typed parameter lists, preventing variadic function declarations; parameters with function types disallowed.
  • Structs/unions were limited: no assignments, function parameters/returns, or compound initializers for 'auto' structs/unions.
  • Compound assignment operators lexed as two tokens (e.g., '+ ='); original '=+' was single token but obsolete.
  • Control reaching 'main' end was implied successful pre-standard, made UB in C89, and special-cased in C99 with implicit return 0.