recursive inclusion

Code, algorithms, languages, construction...
Post Reply
benstoker
Posts: 110
Joined: Thu Jun 10, 2010 7:32 pm
Real Name: Ben Stoker

recursive inclusion

Post by benstoker » Sun Feb 20, 2011 1:27 am

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.

User avatar
Bo Persson
Posts: 14
Joined: Thu Jun 10, 2010 10:34 am
Real Name: Bo Persson
Location: Malmö, Sweden

Re: recursive inclusion

Post by Bo Persson » Sun Feb 20, 2011 12:16 pm

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.

Post Reply