简体   繁体   English

C ++ #include &lt;[文件名]&gt;但#include <string> 不是文件名

[英]C++ #include <[filename]> but #include <string> is not a filename

DUPLICATE: 重复:
When can you omit the file extension in an #include directive? 什么时候可以在#include指令中省略文件扩展名?


I feel a little cleverer after finding: 找到以下内容后,我会变得更聪明:
What is the difference between #include <filename> and #include "filename"? #include <文件名>和#include“文件名”有什么区别?

But in my code I use #include <string> . 但是在我的代码中,我使用#include <string>
string is not a valid filename and the angle brackets are not put in "" . string不是有效的文件名,并且尖括号未放入""

Is this a third way of including other files or how do I have to understand this? 这是包括其他文件的第三种方式,还是我必须如何理解?
In other words, what is <string> ? 换句话说,什么是<string>

string is not a valid filename string不是有效的文件名

It is. 它是。 The name of the header file is literally string . 头文件的名称实际上是string Search your include paths, eg: 搜索您的包含路径,例如:

find /usr/include /usr/local/include -name "string"

and you will have some results. 你会得到一些结果。

What are file extensions? 什么是文件扩展名?

They are some OS (popularly windows ) own way to identify file type to use its default app to open it. 它们是某些操作系统(通常是Windows)自己的识别文件类型的方法,以使用其默认应用程序将其打开。 Whereas Mac and Linux use MIME for identification of file type. 而Mac和Linux使用MIME来识别文件类型。

“MIME” stands for Multipurpose Internet Mail Extensions “ MIME”代表多用途Internet邮件扩展

So in this case of library its the same. 因此,在这种情况下,库是相同的。 It is made using MIME type and since our windows os dont need to open that file other than a using specific IDE we are saved form a problem of file identification. 它是使用MIME类型制成的,并且由于我们的Windows操作系统不需要使用特定的IDE来打开该文件,因此我们可以避免出现文件识别问题。

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

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