Contra implicit declarations of struct types

Today one of my coworkers ran into this snippet of code:

namespace N {
}

#include <sys/socket.h>

int main() {
}


Clang complains:

prog.cc: In function 'int main()':

Moving the #include above namespace N makes the compiler Do The Right Thing, of course. The question is, why do we allow the compiler to do the wrong thing in the first place?