Consider the following code block:
void foo(){
int a = div(1,2);
}
This normally will not compile, as the div
function has not been declared. However, if I preceed the code with #include <map>
, the code compiles. Why is map
pulling in identifiers into the global namespace, and why the div
function in particular? Is there a way to avoid this?
[mcve]
#include <map>
void foo(){
int a = div(1,2);
}
int main()
{
foo();
}
live link - https://godbolt.org/z/Ye8rv4MTc
clang - <source>:4:7: error: no viable conversion from 'div_t' to 'int'
gcc - <source>:4:11: error: 'div' was not declared in this scope
MSVC - <source>(4): error C2440: 'initializing': cannot convert from 'div_t' to 'int'