Header files without .h in C ++

I'm having problems with standard header files like iostream.h and fstream.h. On my system under usr/include/c++/4.3 none of the files have the extension “.h” (for example, it’s just “iostream” and not “iostream.h"). That would be fine and dandy, but I'm trying to use another DCMTK library that does things like #include<iostream.h> . Unfortunately, on my system there is no such thing as "iostream.h", only "iostream", that is, my compiler gives me errors like error: iostream.h: No such file or directory .

I think I could create softlinks from iostream.h to iostream, but it seems that this can create, first of all, problems in the future, and, secondly, it is really annoying. Is there any other solution?

Just for completeness, the command I give to compile a 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 under dicom / include, and the library is under dicom / lib, and is called libdcmdata.a.

Thanks!

+4
source share
4 answers

I would suggest you look here . This explains why and when iostream.h / iostream was born, why it exists and how you should solve these problems.

Basically, iostream.h should consider DEPRECATED UNRELIABLE and IMPLEMENTATION FEATURES and using iostream can cause errors instead.

+7
source

Just create a new iostream.h file that has one line: #include <iostream> . This seems like a big mistake to DCMTK because the standard is that there should not be .h in these file names.

+6
source

These headers are outdated / pre-standard. In gcc, I believe that they are now found as #include <backward/iostream.h> etc.

On the other hand, if the library you are linking to requires an older incompatible version of the standard library, you may have additional problems in front of you.

+3
source

I would fix the (deprecated) library. You can use the regular expression search and replace in place to do this:

 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 recursively affects all files from the path you start from.

+1
source

Source: https://habr.com/ru/post/1315926/


All Articles