Are C++ #ifndef preprocessor statements slow?

110 Views Asked by At

I've heard some things online, both positive and negative, about preprocessor statements, and I was just curious as to how fast these are.

Say you include the same library (which has #ifndef guards) 5 times, will it take any significantly longer period of time to run, or is it so miniscule it has no real effect?

I might have missed one, but didn't find any answer to this elsewhere.

1

There are 1 best solutions below

1
John Zwinck On BEST ANSWER

Compilers have been smart about header include guards for many years. They know that including the same header many times is very common, and they have optimizations to deal with it.

So, don't worry about this. If you want to speed up your build, first find out what part of it is slow.