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

  • Thread starter Thread starter Chromium
  • Start date Start date
  • Tags Tags
    C++
AI Thread Summary
C++ compilers often compile the same header files multiple times when different source files include them, leading to inefficiencies. However, many modern compilers, like Microsoft's Visual C++, utilize precompiled headers to optimize compilation time and resource usage. This feature can be toggled on or off depending on the compiler settings, allowing developers flexibility in managing compilation processes.
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?
 
Technology 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)?
 
On/off, as you wish.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top