Does it matter whether #include iostream or #include "iostream"?


Yesterday I wrote in error #include "iostream" and I did not realize because the compiler did not give an error. Later I realized and I was surprised.

I've tried with this little program:

// Fichero a.h
#ifndef A_H
#define A_H
#endif // A_H

// Fichero a.cpp
#include <iostream>
#include "a.h"
int main(void) {
    std::cout << "Hola Mundo" << std::endl;
    return 0;

Which works as expected.
It also works if I put the two includes with double quotes " " , this has surprised me.
If I put them the two includes with less major < > I get a compilation error, which is what I expect:


a.cpp: 2: 15: fatal error: a.h: No such file or directory

I thought that:

  • #include < > is for system headers or libraries.
  • #include " " is for programmer headers.

But it's clear that not because iostream can also be included with " " .
Can I just include everything with " " ?
Or could it have any adverse effect doing it all with " " ? And if so, what criteria to use to decide each include if done with " " or < > ?

asked by Jose Antonio Dura Olmos 31.12.2015 в 15:45

1 answer


Indeed, both includes are not necessarily interchangeable.

#include <archivo>

This type of include tries to locate the file in the system directories. If the file in question can not be found, the compilation will end with an error.

#include "archivo"

This other include looks for the file in the project directories. If the search is unsuccessful, then the file will be located in the system directories. This include is, therefore, more complete than the version with brackets.

Although a project can compile perfectly if all includes are written with quotes, it is not a particularly recommended practice. Keep in mind that the compilations in

answered by 31.12.2015 / 16:00