Search code examples
c++include

Will "#include"s in C++ still work on other PCs if they have absolute paths?


I have a question about how exactly C++ #include statements work. So, let's say you have something like this:

#include <C:\path\to\library\header.h>

An #include with an absolute path. Now, say you run your program which requires this library. Will it still work on another computer, even if it is not a standard library? Will the header be included in your .exe file, or does #include search for the header when the program actually runs?

Thank you for your help.


Solution

  • Will “#include”s in C++ still work on other PCs if they have absolute paths?

    On the condition that the system where the program is compiled has that file in the specified path, yes they work. However, this is not a reasonable requirement.

    Will the header be included in your .exe file, or does #include search for the header when the program actually runs?

    Neither. Header files are used in compilation.