0

Is it me or does it seem that cmath in VS12 is polluting the global namespace, by in every case including math.h? This way once it is included, symbols like isfinite are in the global namespace (whereas I would expect it only to be usable via std::isfinite). Am I missing something or is there a way to force the correct behavior in VS12?

abergmeier
  • 13,224
  • 13
  • 64
  • 120
  • What do you think is the correct behaviour? AFAIK, `cmath` is allowed to `#include math.h`... – Walter Oct 27 '15 at 08:53
  • 2
    Related: http://stackoverflow.com/questions/11085916/why-are-some-functions-in-cmath-not-in-the-std-namespace – Avi Ginsburg Oct 27 '15 at 08:53
  • 1
    Also related: http://stackoverflow.com/questions/6215467/cmath-header-confusion. Note that this is not a Visual Studio specific problem, clang (libc++) and gcc (libstdc++) headers do the using-pull-up, too. – dhke Oct 27 '15 at 08:57
  • @Walter The expected behavior is to not put public API symbols into global namespace, since then I could also use `math.h` directly. They may include `math.h` but then it would need some magic to wrap symbols in `std`. – abergmeier Oct 27 '15 at 08:59
  • 1
    @abergmeier Read [Mike Seymour's](http://stackoverflow.com/a/11086087/2899559) quote of the standard: "It is unspecified whether these names are first declared within the global namespace scope..." – Avi Ginsburg Oct 27 '15 at 09:07
  • @AviGinsburg I stand corrected. And this is soo annoying. – abergmeier Oct 27 '15 at 09:09

0 Answers0