Discussion
Will it result in to an error if a header file is included twice?
Answer: C
Correct answer: It is compiler dependent.
It depends on what the header contains and how strictly the compiler treats a repeat. A header with an include guard is harmless however often it is named, and repeating a macro definition or a function prototype identically is allowed. But a header that defines a type or a variable will, on a second inclusion, produce a duplicate definition - and older compilers reject some repeats that newer ones tolerate. Guarding the header removes the question entirely.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development