Work on a large project allows in some cases to test some theories concerning a programming language.
It was always interesting if the build is really accelerated by using the #pragma once directive instead of the classic #ifndef #define #endif .
Check this acceleration on a small project is quite problematic, because if the project is going on average for 20 seconds, then we will most likely not see a tangible acceleration, because the assembly time will always float from 17 to 23 seconds.
But I had free time and managed to test this theory on a large project.
What we have:
Question: Will the project build speed change if all
#ifndef #define #endif
changes in header files to
To check this, you need to replace defaines with pragma once in
- Compiler MSVC 2017
Not to be unsubstantiated, here is a screenshot of a commit from Tortoise Git, which shows the changes in 4874 files
To save all the files, I wrote a python script, I am not the enemy myself, to fix all these files manually. Of course, not everything went smoothly and I had to fix something, but in this case it was not so much work.
In the end, I did not see the difference.
Before the change, the project compiled 15 minutes 52 seconds on average.
After the change, the project was compiled for 15 minutes 50 seconds on average.
If some compilers do optimizations, then this should be included with special flags. In fact, a frontal change does not give anyone an increase in assembly speed.
If you had a reverse experience, please accomplish your goal, and tell me how you achieved speeding up the assembly with #pragma once.