简体   繁体   English

如果其他 PC 具有绝对路径,C++ 中的“#include”是否仍能在其他 PC 上工作?

[英]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.我有一个关于 C++ #include语句究竟是如何工作的问题。 So, let's say you have something like this:所以,假设你有这样的事情:

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

An #include with an absolute path.带有绝对路径的#include 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?头文件会包含在您的 .exe 文件中,还是#include在程序实际运行时搜索头文件?

Thank you for your help.感谢您的帮助。

Will “#include”s in C++ still work on other PCs if they have absolute paths?如果其他 PC 具有绝对路径,C++ 中的“#include”是否仍能在其他 PC 上工作?

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?头文件会包含在您的 .exe 文件中,还是 #include 在程序实际运行时搜索头文件?

Neither.两者都不。 Header files are used in compilation.头文件用于编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM