Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location of iostream.h in GCC

Tags:

c++

gcc

I am getting back into C++ world after nearly a decade. I have installed GCC and wrote a preliminary program on my Windows 7 box. I have the following question:

When I say #include <iostream.h> , I get an error saying file not found. I have to say #include <iostream> to get it working. Further, when I go to the folder where GCC is installed, I could not find the hearder file by either name. Where is iostream getting picked from?

like image 446
Aadith Ramia Avatar asked Dec 11 '12 12:12

Aadith Ramia


2 Answers

<iostream> is the standard C++ header you need to include. Where it is depends on your platform. On mine, it is in

/usr/include/c++/4.4.3/iostream

You can find out details of g++ configuration with

g++ --verbose

This prints out, among other things,

--with-gxx-include-dir=/usr/include/c++/4.4

like image 78
juanchopanza Avatar answered Oct 25 '22 17:10

juanchopanza


The .h headers (such as iostream.h) have been deprecated in favor of the "modern" style headers (iostream). This ensures that the implementation does not need to provide the headers as a file physically located on the disk. It is free to choose any appropriate implementation.

For example, <math.h> requires the implementation to provide a file with this name, but if you only specify <cmath>, the implementation is free to provide the math utilities as it pleases, without the need for physical file.

Additionally, the .h headers put their declarations in the global namespace, whereas the "non-.h" headers put their declarations in the std namespace. As a result, the new headers are unlikely to cause any naming conflicts.

Edit As Basile Starynkevitch pointed out in the comment, this notion is not restricted to C++ alone, but the C standard also supports it.

like image 33
Masked Man Avatar answered Oct 25 '22 18:10

Masked Man