Fix build error on macOS in Viewer::pollEvents() calling apply methods#15
Merged
Conversation
Compiling on macOS v10.13.6, using clang version Apple LLVM version 10.0.0 (clang-1000.11.45.5)
There is a compiler error in all `apply()`-methods in `Viewer::pollEvents()` dealing with enum classes:
```
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/src/vsg/viewer/Viewer.cpp:13:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/viewer/Viewer.h:15:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/viewer/Window.h:17:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/ui/UIEvent.h:15:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/core/Inherit.h:15:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/core/Allocator.h:20:
In file included from /Users/oleg/dev/osg-vulkan/vsg/src/include/vsg/io/stream.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/istream:163:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:208:20: note: candidate function
basic_ostream& operator<<(unsigned short __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:209:20: note: candidate function
basic_ostream& operator<<(int __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:206:20: note: candidate function
basic_ostream& operator<<(bool __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:207:20: note: candidate function
basic_ostream& operator<<(short __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:210:20: note: candidate function
basic_ostream& operator<<(unsigned int __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:211:20: note: candidate function
basic_ostream& operator<<(long __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:212:20: note: candidate function
basic_ostream& operator<<(unsigned long __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:213:20: note: candidate function
basic_ostream& operator<<(long long __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:214:20: note: candidate function
basic_ostream& operator<<(unsigned long long __n);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:215:20: note: candidate function
basic_ostream& operator<<(float __f);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:216:20: note: candidate function
basic_ostream& operator<<(double __f);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:217:20: note: candidate function
basic_ostream& operator<<(long double __f);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:788:1: note: candidate function [with _Traits = std::__1::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __os, char __c)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:755:1: note: candidate function [with _CharT = char, _Traits = std::__1::char_traits<char>]
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:795:1: note: candidate function [with _Traits = std::__1::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:802:1: note: candidate function [with _Traits = std::__1::char_traits<char>]
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
```
Possible solutions:
1) This proposed change. However, I'm not sure about header file where to define the `operator<<`. in `UIEvent.h` or new header file?
2) Defining same method for `KeySymbol` in `KeyEvent.h` and `ButtonMask` in `PointerEvent.h`, e.g.
```c++
std::ostream& operator<<(std::ostream& os, const ButtonMask& obj)
{
os << static_cast<std::underlying_type<ButtonMask>::type>(obj);
return os;
}
```
3) Calling `static_cast` in corresponding methods
Collaborator
|
Tomorrow I will do a clang build under Linux to see if I can recreate the compile error. So far I have been putting in the << and >> operator implementations into include/vsg/io/stream.h. FYI, The actual usage in Viewer::pollEvents() is currently for development/debugging purposes and will disappear once the platform specific Window implementations are complete. |
Owner
|
I tried clang under Linux and it failed as well. I have merged you change as it, but then moved the enum << operator into include/vsg/io/steam.h to make it available for a wider range of uses. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiling on macOS v10.13.6, using clang version Apple LLVM version 10.0.0 (clang-1000.11.45.5)
There is a compiler error in all
apply()-methods inViewer::pollEvents()dealing with enum classes:Possible solutions:
operator<<. inUIEvent.hor new header file?KeySymbolinKeyEvent.handButtonMaskinPointerEvent.h, e.g.static_castin correspondingapply()methodsPull Request Template
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Executed sample programs on macOS
Checklist: