ProgrammingModerateProduct company OA

A header config.h is wrapped as `#ifndef CONFIG_H` / `#define CONFIG_H` / … / `#endif`. What problem does this prevent?

  1. A. Macros from the header becoming visible in other source files
  2. B. The header's contents being processed twice in one translation unit, which would redefine its types
  3. C. The header's functions being compiled into every object file
  4. D. The header being linked into the program twice

Correct answer: B. The header's contents being processed twice in one translation unit, which would redefine its types

An include guard works per translation unit: the second time the same .c file pulls in config.h (often indirectly), CONFIG_H is already defined and the body is skipped, avoiding duplicate struct and typedef definitions. Linking and other source files are unaffected.

More C Programming questions

Exams that ask this topic