F5 Networks Interview Question
Software Engineer / DevelopersGood question. The programmer will end up with circular dependency. For example, if a.h contains structure A and a function void funA(A, B) and b.h contains structure B and a function void funB(A, B).
When these files are included in a source file, the compiler throws error, "one of the structure definition is not available". It is because none of the order "a.h followed by b.h" or "b.h followed by a.h" can provide the complete declaration of structures.
This can be solved by forward declaration of structures, passing references (pointers), strictly following top-down declaration across the common project files, etc...
Keeps printing in a loop:
- blue_skin November 10, 2010from a.h:<linenumber>,
from b.h:<linenumber>,
from a.h:<linenumber>,
from b.h:<linenumber>,
from b.h:<linenumber>,
a.h:<linenumber>: error: previous definition of 'class A'
....
.from a.h:<linenumber>,
from b.h:<linenumber>,
..goes on for sometime n stops