Do C++ Compilers Repeatedly Process the Same Header Files?

  • Context: C/C++ 
  • Thread starter Thread starter Chromium
  • Start date Start date
  • Tags Tags
    C++
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
Chromium
Messages
56
Reaction score
0
Is it true that most, if not all, C++ compilers tend to compile the same .h files over and over again? Say there are two .cpp files that include the same .h file, and the compiler processes one of these .cpp files & all its included header files as well. Once it gets to the second .cpp file, it doesn't recognize that it has seen the one .h file before, and so it just processes that file again, right?
 
Physics news on Phys.org
Not necesarrilly. Visual compilers (Microsoft) prepare something they call precompiled header to save on resources/compilation time. I suppose other compilers are able to do the same.
 
Oh, I see. Although I guess it makes more sense to use precompiled headers, isn't it possible to turn that feature off (I guess it depends on the compiler)?