Hacker News new | past | comments | ask | show | jobs | submit login

I have tried running the example in the examples folder, but it fails to compile. Seeing the errors:

    /opensource/implot3d/implot3d.cpp:2650:20: error: no member named 'sin' in namespace 'std'
 2650 |     float s = std::sin(half_angle);
      |               ~~~~~^
  /opensource/implot3d/implot3d.cpp:2654:14: error: no member named 'cos' in namespace 'std'
 2654 |     w = std::cos(half_angle);
      |         ~~~~~^
  /opensource/implot3d/implot3d.cpp:2670:14: error: no member named 'fabs' in namespace 'std'
 2670 |     if (std::fabs(normalized_dot - 1.0f) < epsilon) {
      |         ~~~~~^
  /opensource/implot3d/implot3d.cpp:2680:14: error: no member named 'fabs' in namespace 'std'
 2680 |     if (std::fabs(normalized_dot + 1.0f) < epsilon) {
      |         ~~~~~^
  /opensource/implot3d/implot3d.cpp:2682:45: error: no member named 'fabs' in namespace 'std'
 2682 |         ImPlot3DPoint arbitrary_axis = std::fabs(v0.x) > std::fabs(v0.z) ? ImPlot3DPoint(-v0.y, v0.x, 0.0f)
      |                                        ~~~~~^
  /opensource/implot3d/implot3d.cpp:2682:63: error: no member named 'fabs' in namespace 'std'
 2682 |         ImPlot3DPoint arbitrary_axis = std::fabs(v0.x) > std::fabs(v0.z) ? ImPlot3DPoint(-v0.y, v0.x, 0.0f)
      |                                                          ~~~~~^
  /opensource/implot3d/implot3d.cpp:2695:24: error: no member named 'acos' in namespace 'std'
 2695 |     float angle = std::acos(normalized_dot);
      |                   ~~~~~^
  /opensource/implot3d/implot3d.cpp:2697:20: error: no member named 'sin' in namespace 'std'
 2697 |     float s = std::sin(half_angle);
      |               ~~~~~^
  /opensource/implot3d/implot3d.cpp:2701:16: error: no member named 'cos' in namespace 'std'
 2701 |     q.w = std::cos(half_angle);
      |           ~~~~~^
  /opensource/implot3d/implot3d.cpp:2707:17: error: no member named 'sqrt' in namespace 'std'
 2707 |     return std::sqrt(x * x + y * y + z * z + w * w);
      |            ~~~~~^
  /opensource/implot3d/implot3d.cpp:2786:26: error: no member named 'acos' in namespace 'std'
 2786 |     float theta_0 = std::acos(dot);        // Angle between input quaternions
      |                     ~~~~~^
  /opensource/implot3d/implot3d.cpp:2788:28: error: no member named 'sin' in namespace 'std'
 2788 |     float sin_theta = std::sin(theta);     // Sine of interpolated angle
      |                       ~~~~~^
  /opensource/implot3d/implot3d.cpp:2789:30: error: no member named 'sin' in namespace 'std'
 2789 |     float sin_theta_0 = std::sin(theta_0); // Sine of original angle
      |                         ~~~~~^
  /opensource/implot3d/implot3d.cpp:2791:21: error: no member named 'cos' in namespace 'std'
 2791 |     float s1 = std::cos(theta) - dot * sin_theta / sin_theta_0;



This is a problem in C++ standard around #include<cmath> and #include<math.h>. see https://stackoverflow.com/a/11086087


The linked code is including math.h (transitively), but using the std-namespaced functions provided by cmath. That seems like a bug, but presumably works on at least one platform.


The code doesn't seem to be tested on macOS. To make the example build I had to add an "#include <cmath>" at the top of both implot3d.cpp and implot3d_demo.cpp, this produces an executable which then fails with:

    GLFW Error 65543: NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above
...which is fixed by changing the GLFW window hints like this:

     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
I'll see if I can create a pull-request...

Edit: https://github.com/brenocq/implot3d/pull/7

PS: it looks like the code was tested only on Linux, since the Windows build seems to suffer from the same `std::` prefix problem: https://github.com/floooh/implot3d/actions/runs/12393862255




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: