strange behaviour with c++0x/c++11/c++1y compiler flags and image showing
Ok as the title says I have an issue with loading an image and using different CXX_FLAGS in the compiler. In the project that I am working if I set set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
through the cmakelist file and compile the following code:
// load original image
Mat src = imread("../panther.png");
// check if image is loaded without problems
if(!src.data || src.empty())
{
cerr << "Problem loading image!" << endl;
return -1;
}
imshow("src", src);
Mat3f src_float = src / 255.f;
imshow("src_float", src_float);
I will get the following result:
However, now if I enable the c++11 or c++1y flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
or set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
the src_float
image output changes:
why that, does anyone has a clue and how we can prevent this?
Thanks.
p.s. and yes it is the panther again :-p....
The name ‘c++1y’ is deprecated. (see here). BTW what's happen following debug in opencv ? I suppose that the ‘c++14’ is more strict about casting
@pklab thanks for noting about c++1y I changed it now to c++14. It seems so that you are right in your second assumption as well. However, do you know if we can we bypass this?
ok it seems that there is the same behavior no matter which flag I will use, meaning
-std=c++14
,-std=c++11
or-std=c++0x
, if I do not set any flag and try to print out the default one it is blank. I am using the following command in order to get the status of theCXX_FLAG
:MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
what the blank field suppose to mean....?As you can read hereThe default, if no C language dialect options are given, is -std=gnu11. It's supposed that this will change in the future.