Page 1 of 1

recursive inclusion

Posted: Sun Feb 20, 2011 1:27 am
by benstoker
In Ivanhoe, file "low_depth.c", there is "#include "low_depth.c"". The file recursively includes itself. Why?

Is this just sloppy programming?

And, other Ivanhoe files do this.

Re: recursive inclusion

Posted: Sun Feb 20, 2011 12:16 pm
by Bo Persson
benstoker wrote:In Ivanhoe, file "low_depth.c", there is "#include "low_depth.c"". The file recursively includes itself. Why?

Is this just sloppy programming?

And, other Ivanhoe files do this.
I think they just outsmarted themselves. :-)

There is an include guard that makes the second inclusion different from the first, so the code is compiled once for white and once for black. Doing that in a single file is just too cute, if done on purpose, or just silly if they didn't some up with the idea of having two .c files (low_depth_black and low_depth_white) that include a common set of .h files.