How many nested #if(n)defs?
Rick Murray (539) 13840 posts |
I have a header file that uses a handful of nested #ifndef statements to determine whether or not debug support should be included.
So ‘DEBUG’ will be defined (as ‘1’ but that’s immaterial) so long as at least one of the other debug options are defined. Does anybody know what the limit for nested if(n)def statements is? I just threw together a contrived test, and the compiler had no problems with 50 of them. Update: Okay, for the lulz I did a test for #ifndef A0 through A9, then copypasted it so there were one thousand and two hundred nested conditionals. Didn’t faze CC one bit. Didn’t appear to noticably slow the compiler down, either. I deleted one #endif and the compiler threw errors, so it is chundering through that lot and not just block-optimising it out (despite the painfully obvious repetition). Is there a limit? Or can it keep going until memory runs out? |
Rick Murray (539) 13840 posts |
I give up. Time to perform a full build of my project with the following (1.4MiB of unique definitions) is 31s. I think we can safely say that for all intensive porpoises, there is no limit.
|