79243932

Date: 2024-12-02 11:46:19
Score: 1
Natty:
Report link

The C compiler translates the source code into an assembly code (.s file). Since add is only declared but not defined, the compiler knows the signature (parameters and return type) but doesn't know the implementation. It treats add as an external symbol and assumes the definition will be provided later (likely in another object file or library).The assembler converts the assembly code into machine code, creating an object file (.o file).he assembler creates an entry for the add function in the symbol table as an undefined symbol.The assembler does not reserve memory for the add function. Instead, it simply records the fact that add is a function that will be resolved during the linking phase. During linking, the linker combines all object files and resolves the addresses for external symbols like add. If the linker cannot find a definition for add, it will throw an undefined reference error.

You could read more about it here : https://www.quora.com/What-happens-if-a-function-is-declared-but-not-defined-in-C

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Khadija Noor