Tuesday, December 22, 2020

Error C2668 'abs': ambiguous call to overloaded function

Error C2668 'abs': ambiguous call to overloaded function
Triangle Renderer Project c:\demo_temp\triangle-renderer-project\triangle renderer project\c3dengine.cpp 5953

  1. Ambiguous overload call to abs(double)
  2. The cplusplus page you cite does not say to include cmath.h. It says cmath. That's the C++ version of math.h. Don't include both. – Rob Kennedy Sep 3 '09 at 15:54

    The header is a C std lib header. It defines a lot of stuff in the global namespace. The header is the C++ version of that header. It defines essentially the same stuff in namespace std. (There are some differences, like that the C++ version comes with overloads of some functions, but that doesn't matter.) The header doesn't exist.

    very clear and thorough answer is the following one:

    Since vendors don't want to maintain two versions of what is essentially the same header, they came up with different possibilities to have only one of them behind the scenes. Often, that's the C header (since a C++ compiler is able to parse that, while the opposite won't work), and the C++ header just includes that and pulls everything into namespace std. Or there's some macro magic for parsing the same header with or without namespace std wrapped around it or not. To this add that in some environments it's awkward if headers don't have a file extension (like editors failing to highlight the code etc.). So some vendors would have be a one-liner including some other header with a .h extension. Or some would map all includes matching to (which, through macro magic, becomes the C++ header when __cplusplus is defined, and otherwise becomes the C header) or or whatever.

    That's the reason why on some platforms including things like , which ought not to exist, will initially succeed, although it might make the compiler fail spectacularly later on.

  3. 3D Software Rendering Engine - Part I
  4. when I compile this project, I got this error message:

    I fixed it by using their new header file names: such as bracket cmath braket instead of cmath.h;

No comments:

Post a Comment