The name to search is the name of the function; a special argument-dependent search is applied here. (Note that ADL is part of an unqualified name lookup for function names.)
These function names are looked up in the namespaces of their arguments, in addition to the realms and namespaces that are considered by the usual unskilled name lookup.
First you include string.h , which introduces the name memcpy into the global namespace.
And AA declared in the global namespace; then when calling memcpy(&a, &a, sizeof(a)); the namespace in which AA declared (i.e. the global namespace) will be declared, and memcpy declared in the my namespace will be found to be an ordinary unqualified name search , so the call is ambiguous.
On the other hand, BB does not have such a problem, since it is not declared in the global namespace (and then ADL will not act for it).
source share