This is an annoying hole in my knowledge and I can't seem to find an answer.
I understand why it works during compilation (the header is never compiled in isolation, so stdafx.h will have already been included), but not why it works while editing.
Say I have the following files:
stdafx.h
#pragma once
#include <string>
MyFunction.h
#pragma once
void MyFunction( std::string Text );
MyFunction.cpp
#include "stdafx.h"
#include "MyFunction.h"
void MyFunction( std::string Text )
{
// implementation here
}
When I'm editing MyFunction.h, how does Intellisense find std::string
for the purpose of auto-complete, not showing it as undefined, etc?
I ask partly out of curiosity and partly because if I don't know the mechanism then I can't know if I'm at risk of breaking it or how to fix it when I do. I've seen it break a number of times, causing most of the header in question to be marked as an error, and then at some point it either just fixes itself or I accept it isn't coming back and add a few extra strategic includes into the header.
Just to repeat: I'm not asking how std::string is found during compilation, I'm asking how it's found when editing the header file.