Bird
0
0

Why does the linker sometimes produce an 'undefined reference' error during the C compilation process?

hard📝 Conceptual Q10 of 15
C - Basics and Execution Environment
Why does the linker sometimes produce an 'undefined reference' error during the C compilation process?
ABecause a function or variable is declared but not defined in any object file
BBecause the preprocessor failed to include header files
CBecause the assembler generated incorrect machine code
DBecause the source code has syntax errors
Step-by-Step Solution
Solution:
  1. Step 1: Understand linker's role

    The linker combines object files and resolves references to functions and variables.
  2. Step 2: Cause of 'undefined reference'

    If a function or variable is declared but missing definition in any object file, linker errors occur.
  3. Final Answer:

    Function or variable declared but not defined -> Option A
  4. Quick Check:

    Undefined reference = missing definition at link time [OK]
Quick Trick: Undefined reference means missing function or variable definition [OK]
Common Mistakes:
  • Blaming preprocessor for linker errors
  • Confusing syntax errors with linker errors
  • Assuming assembler causes undefined references

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes