Compiling with clang C++11 on Mac OS X (Bug #2263)


Added by Samuel Williams over 12 years ago. Updated about 12 years ago.


Status:Done Start date:2012-08-13
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:build/install
Target version:-
Affected version:2.4.2 Operating System:
Difficulty: HW Platform:
Pull request:

Description

Constant expression violates the new C++11 narrowing rules:

[ 22%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/arithm.cpp.o
/Users/samuel/Documents/Programming/Graphics/Dream/examples/Transform Flow/ext/OpenCV-2.4.2/modules/core/src/arithm.cpp:444:51: error: constant expression evaluates to
4294967295 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~
/Users/samuel/Documents/Programming/Graphics/Dream/examples/Transform Flow/ext/OpenCV-2.4.2/modules/core/src/arithm.cpp:444:51: note: override this message by inserting
an explicit cast
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~
static_cas)<int>(
/Users/samuel/Documents/Programming/Graphics/Dream/examples/Transform Flow/ext/OpenCV-2.4.2/modules/core/src/arithm.cpp:444:75: error: constant expression evaluates to
4294967295 which cannot be narrowed to type 'int' [-Wc++11-narrowing]
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~
/Users/samuel/Documents/Programming/Graphics/Dream/examples/Transform Flow/ext/OpenCV-2.4.2/modules/core/src/arithm.cpp:444:75: note: override this message by inserting
an explicit cast
static int CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };
^~~~~~~~
static_cas)<int>(
2 errors generated.
make2: * [modules/core/CMakeFiles/opencv_core.dir/src/arithm.cpp.o] Error 1
make1:
[modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make: *
* [all] Error 2


Associated revisions

Revision 109e71e4
Added by Roman Donchenko about 11 years ago

Merge pull request #2263 from ilya-lavrenov:include_fix

History

Updated by Samuel Williams over 12 years ago

Recommend changing that line to:

static unsigned CV_DECL_ALIGNED(16) v64f_absmask[] = { 0xffffffff, 0x7fffffff, 0xffffffff, 0x7fffffff };

But, I'm not sure what it does so, this makes it compile, but it might have unintended consequences.

Updated by Evgeny Talanin over 12 years ago

  • Category set to build/install

Updated by Samuel Williams over 12 years ago

I found this works pretty well:

CC=clang CXX=clang++ CFLAGS='-m64' CXXFLAGS='-std=c++0x -stdlib=libc++ -m64 -Wno-c++11-narrowing' cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=x86_64 ..

Then you just compile as usual.

But, I'm not sure if this is a good long term fix.

Updated by Vadim Pisarevsky about 12 years ago

the problem should have been fixed in 2.4 branch

  • Assignee set to Vadim Pisarevsky
  • Affected version set to 2.4.2
  • Status changed from Open to Done

Also available in: Atom PDF