Suppose we have a pretty big amount of files in a project, so writing #include "somefile" to all of them will take a long time, so it there a way to include "somefile" into all files in the project?
If it is visual studio, use the /FI option (force include).
https://msdn.microsoft.com/en-us/library/8c5ztk84.aspx
Some compilers have an option for this. For example, the option for GCC is -include.
-includefileProcess file as if "
#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.If multiple
-includeoptions are given, the files are included in the order they appear on the command line.
Of course, using such option will make your project depend on the support for such compiler feature. A portable solution is to simply edit all your files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With