• Advertisement
Sign in to follow this  

how does the compiler handle this ?

This topic is 4619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

head1.h include head2.h and head2.h include head1.h but this way all is ok ,so how does the compler handle this ?

Share this post


Link to post
Share on other sites
Advertisement
include guards


#ifndef __SOME_COOL_NAME
#define __SOME_COOL_NAME

// ...

#endif

Everything between the #ifndef and the #endif will only be included once.

Share this post


Link to post
Share on other sites
And if you don't have the include guards, then the compiler will give an error after a certain depth (around 100 recursions sounds sensible)

Share this post


Link to post
Share on other sites
Hm, after giving this a second thought, I think the compiler does not handle this it all - the preprocessor does.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement