Skip to content

fegetround and fesetround not in std namespace.  #26000

@vapniks

Description

@vapniks

System Information

OpenCV version: 4.x
Operating System / Platform: Ubuntu 18.04 / guix
Compiler & compiler version: GCC 13.2.0

Detailed description

I get the error displayed below when I try to build opencv with make (after running cmake).
ChatGPT told me that the fesetround & fegetround functions should not be prefixed by std:: since they are part of the C standard library (fenv.h), not the C++ standard library. After removing the std:: prefixes the error was fixed.

[ 52%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/elementwise_layers.cpp.o
cd /home/joe/Downloads/opencv-build/modules/dnn && /usr/bin/ccache /home/joe/.guix-profile/bin/c++ -DCVAPI_EXPORTS -DCV_OCL4DNN=1 -DENABLE_PLUGINS -DHAVE_FLATBUFFERS=1 -DHAVE_PROTOBUF=1 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/joe/Downloads/opencv-build/3rdparty/ippicv/ippicv_lnx/icv/include -I/home/joe/Downloads/opencv-build/3rdparty/ippicv/ippicv_lnx/iw/include -I/home/joe/Downloads/opencv-4.x/modules/dnn/include -I/home/joe/Downloads/opencv-build/modules/dnn -I/home/joe/Downloads/opencv-4.x/modules/core/include -I/home/joe/Downloads/opencv-4.x/modules/imgproc/include -I/home/joe/Downloads/opencv-4.x/modules/dnn/misc/caffe -I/home/joe/Downloads/opencv-4.x/modules/dnn/misc/tensorflow -I/home/joe/Downloads/opencv-4.x/modules/dnn/misc/onnx -I/home/joe/Downloads/opencv-4.x/modules/dnn/misc/tflite -I/home/joe/Downloads/opencv-4.x/3rdparty/include/opencl/1.2 -isystem /home/joe/Downloads/opencv-build -isystem /home/joe/Downloads/opencv-4.x/3rdparty/flatbuffers/include -isystem /home/joe/Downloads/opencv-4.x/3rdparty/protobuf/src -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-sign-compare -Wno-invalid-offsetof -O3 -DNDEBUG -DNDEBUG -fPIC -std=c++11 -MD -MT modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/elementwise_layers.cpp.o -MF CMakeFiles/opencv_dnn.dir/src/layers/elementwise_layers.cpp.o.d -o CMakeFiles/opencv_dnn.dir/src/layers/elementwise_layers.cpp.o -c /home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp
/home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp: In member function ‘float cv::dnn::RoundFunctor::calculate(float) const’:
/home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp:1741:43: error: ‘fegetround’ is not a member of ‘std’; did you mean ‘fegetround’?
1741 | int old_rounding_direction = std::fegetround();
| ^~~~~~~~~~
In file included from /home/joe/.guix-profile/include/c++/fenv.h:36,
from /home/joe/.guix-profile/include/c++/cfenv:41,
from /home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp:56:
/home/joe/.guix-profile/include/fenv.h:104:12: note: ‘fegetround’ declared here
104 | extern int fegetround (void) __THROW attribute_pure;
| ^~~~~~~~~~
/home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp:1742:14: error: ‘fesetround’ is not a member of ‘std’; did you mean ‘fesetround’?
1742 | std::fesetround(FE_TONEAREST);
| ^~~~~~~~~~
/home/joe/.guix-profile/include/fenv.h:107:12: note: ‘fesetround’ declared here
107 | extern int fesetround (int __rounding_direction) __THROW;
| ^~~~~~~~~~
/home/joe/Downloads/opencv-4.x/modules/dnn/src/layers/elementwise_layers.cpp:1744:14: error: ‘fesetround’ is not a member of ‘std’; did you mean ‘fesetround’?
1744 | std::fesetround(old_rounding_direction);
| ^~~~~~~~~~
/home/joe/.guix-profile/include/fenv.h:107:12: note: ‘fesetround’ declared here
107 | extern int fesetround (int __rounding_direction) __THROW;
| ^~~~~~~~~~

Steps to reproduce

make

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions