# 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() {
struct sockaddr *x = N::Foo();
}


Clang complains:

prog.cpp: In function 'int main()':
prog.cpp:8:33: error: cannot convert 'N::sockaddr*' to 'sockaddr*' in initialization
struct sockaddr *x = N::foo();
^
prog.cpp:2:12: note: class type 'N::sockaddr' is incomplete

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?