在C ++中没有.h的头文件

时间:2022-03-30 15:07:06

I'm having trouble including standard header files like iostream.h and fstream.h. On my system, under usr/include/c++/4.3, none of the files have the ".h" extension (for example, it's just iostream not iostream.h).

我遇到麻烦,包括像iostream.h和fstream.h这样的标准头文件。在我的系统上,在usr / include / c ++ / 4.3下,没有任何文件具有“.h”扩展名(例如,它只是iostream而不是iostream.h)。

That would be fine and dandy, but I'm trying to use another library, DCMTK, which does things like #include<iostream.h>. Unfortunately, there's no such thing as "iostream.h" on my system, only "iostream", meaning my compiler gives me errors like error: iostream.h: No such file or directory.

这样会很好,但是我正在尝试使用另一个库DCMTK,它可以执行#include 之类的操作。不幸的是,在我的系统上没有“iostream.h”这样的东西,只有“iostream”,这意味着我的编译器给了我错误,如错误:iostream.h:没有这样的文件或目录。

I guess I could create softlinks from iostream.h to iostream, but that seems like it might create, first of all, troubles down the road, and second of all, be really irritating. Is there another solution?

我想我可以创建从iostream.h到iostream的软链接,但这似乎可能会产生麻烦,首先是麻烦,其次,真的很烦人。还有其他解决方案吗?

Just for completeness, the command I'm giving to compile the thing is

为了完整性,我给编译的命令是

g++ -o gc_on_ctp -g -Wall -Idicom/include -Ldicom/lib gc_on_ctp.cpp -ldcmdata

As you can imagine, the header file is located under dicom/include, and the library is under dicom/lib, named libdcmdata.a.

可以想象,头文件位于dicom / include下,库位于dicom / lib下,名为libdcmdata.a。

4 个解决方案

#1


7  

I would suggest you to take a look here. It explains why and when this iostream.h / iostream was born, why it exists and how you should solve these issues.

我建议你看看这里。它解释了为什么以及何时出现iostream.h / iostream,为什么它存在以及如何解决这些问题。

Mainly iostream.h is to be considered DEPRECATED UNRELIABLE and IMPLEMENTATION SPECIFIC and using the iostream in place of that one can cause errors..

主要是iostream.h被认为是不合适的和实现特定的,并且使用iostream代替那个可能会导致错误。

#2


6  

Just create a new iostream.h file that has a single line in it: #include <iostream>. It seems to be a big mistake by DCMTK because the standard is that there should be no .h in these file names.

只需创建一个新的iostream.h文件,其中包含一行:#include 。这似乎是DCMTK的一个大错误,因为标准是这些文件名中不应该有.h。

#3


3  

Those headers are deprecated/pre-standard. On gcc I believe they're located as #include <backward/iostream.h> etc now.

这些标题已弃用/预标准。在gcc上我认为它们现在位于#include 等。

On the other hand if the library you're linking against requires an older incompatible version of the standard library you might have further problems ahead of you.

另一方面,如果您要链接的库需要较旧的不兼容版本的标准库,那么您可能会遇到更多问题。

#4


1  

I would fix the (outdated) library. You can use in-place regex search and replace to do that:

我会修复(过时的)库。您可以使用就地正则表达式搜索和替换来执行此操作:

perl -e "s/iostream.h/iostream/g;" -pi $(find . -iname "*.cpp")

or

find . -iname "*.cpp" -print0 | xargs -0 sed -i 's/iostream.h/iostream/g'

NOTE: Be careful when doing this... it affects all files recursively from the path you start from.

注意:执行此操作时要小心......它会从您开始的路径递归影响所有文件。

#1


7  

I would suggest you to take a look here. It explains why and when this iostream.h / iostream was born, why it exists and how you should solve these issues.

我建议你看看这里。它解释了为什么以及何时出现iostream.h / iostream,为什么它存在以及如何解决这些问题。

Mainly iostream.h is to be considered DEPRECATED UNRELIABLE and IMPLEMENTATION SPECIFIC and using the iostream in place of that one can cause errors..

主要是iostream.h被认为是不合适的和实现特定的,并且使用iostream代替那个可能会导致错误。

#2


6  

Just create a new iostream.h file that has a single line in it: #include <iostream>. It seems to be a big mistake by DCMTK because the standard is that there should be no .h in these file names.

只需创建一个新的iostream.h文件,其中包含一行:#include 。这似乎是DCMTK的一个大错误,因为标准是这些文件名中不应该有.h。

#3


3  

Those headers are deprecated/pre-standard. On gcc I believe they're located as #include <backward/iostream.h> etc now.

这些标题已弃用/预标准。在gcc上我认为它们现在位于#include 等。

On the other hand if the library you're linking against requires an older incompatible version of the standard library you might have further problems ahead of you.

另一方面,如果您要链接的库需要较旧的不兼容版本的标准库,那么您可能会遇到更多问题。

#4


1  

I would fix the (outdated) library. You can use in-place regex search and replace to do that:

我会修复(过时的)库。您可以使用就地正则表达式搜索和替换来执行此操作:

perl -e "s/iostream.h/iostream/g;" -pi $(find . -iname "*.cpp")

or

find . -iname "*.cpp" -print0 | xargs -0 sed -i 's/iostream.h/iostream/g'

NOTE: Be careful when doing this... it affects all files recursively from the path you start from.

注意:执行此操作时要小心......它会从您开始的路径递归影响所有文件。