I am wondering how compiler (or preprocessor) include headers. I have three files. First is header.h, second first.cpp <- and there is #include <iostream>, third <- it contains #include <iostream> too. header.h:#ifndef HEADER_H_#define HEADER_H_struct Student{    std::string imie;    int ocena;};void foo();#endiffirst.cpp:#include <iostream>#include header.hint main(){    Student Jan;    std::cout << It's OK << std::endl;    foo();    return 0;}Second.cpp:#include <iostream>#include header.hvoid foo(){    std::cout << I like Linux << std::endl;}And my question is do the compiler copy code from library twice? Should I cut all iostream from .cpp's to one .h?
Preprocessor and double declaration include in different files
c++;compilation
If you open the source code of the iostream header, you will see it includes header guard as well, meaning the header will be included only once.For example the GCC guards the header with the _GLIBCXX_IOSTREAM constant.