Skip to content

fixed inconsistent return type #4275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2019

Conversation

ingphos
Copy link
Contributor

@ingphos ingphos commented Jun 24, 2019

Fixes the following error (GNU Make 4.2.1):
error: inconsistent types 'bool' and 'int' deduced for lambda return type

error: inconsistent types 'bool' and 'int' deduced for lambda return type
@dorodnic
Copy link
Contributor

Hi @battlecry231
Thank you for contributing!

@@ -114,7 +114,7 @@ int rs2_gl_is_frame_extendable_to(const rs2_frame* f, rs2_gl_extension extension
if (!gpu->get_gpu_section().on_gpu()) return false;
return true;
}
default: return 0;
default: return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@battlecry231 , this seem little weird as one would except that the compiler complains about the return false in the above case RS2_GL_EXTENSION_VIDEO_FRAME statement.
The default return (int) is actually consistent with the function's signature.
Can you post the Make error you see ?

Copy link
Contributor Author

@ingphos ingphos Jun 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the error when I try to compile with default: return 0;:

[ 54%] Building CXX object src/gl/CMakeFiles/realsense2-gl.dir/rs-gl.cpp.o
/home/***/Downloads/librealsense/src/gl/rs-gl.cpp: In lambda function:
/home/***/Downloads/librealsense/src/gl/rs-gl.cpp:117:21: error: inconsistent types ‘bool’ and ‘int’ deduced for lambda return type
     default: return 0;
                     ^
make[2]: *** [src/gl/CMakeFiles/realsense2-gl.dir/build.make:102: src/gl/CMakeFiles/realsense2-gl.dir/rs-gl.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:407: src/gl/CMakeFiles/realsense2-gl.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Edit:
But you got a point there with the return type of the function. Though the conversion from bool to int is implicit it may be better to always return a real integer, hence changing every return false; to return 0; and the return true; in line 115 to return 1; in the function rs2_gl_is_frame_extendable_to.

@ev-mp ev-mp merged commit d3460c2 into IntelRealSense:development Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants