I m trying to understand how an IDE (I'm using Visual Studio) knows where to find the implementation for a header file's declarations.
Let's say that I have 2 cpp files and 1 header file:
main.cpp
, containsmain()
function and includesperson.h
person.h
, contains some class declarations that are implemented inperson.cpp
person.cpp
, contains the implementation of theperson.h
declarations, and also definesperson.h
So my understanding is that main.cpp
and person.cpp
know where to find the function declarations, but person.h
has to search in some .cpp
file for these implementations.
Now, how does Visual Studio keeps track of this? Each time a new header file is created, does VS needs to parse every .cpp
file in the project to find where the declarations are implemented? Header files don't have any declaration of which .cpp
files to search for, yet it finds them! Is Visual Studio scanning each .cpp
file in the project?
So, what happens in a large project, with hundreds, or thousands of .cpp
files? This does not appear to be very efficient, so I figure VS must do it in a different way. Do you know how?
PS: Not about compiler/linker process, but rather how VS IDE works (even before compiling or link the final exe)