From fdefa8c077e0d854984b6d40622f633fe1b1b6cf Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Fri, 9 Sep 2016 19:12:26 +0200 Subject: [PATCH] resource-encapsulation: Avoid reinterpret_cast in const_expr As unsupported in C++11 standard and g++-6 or clang Reported error message is: service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp:368:13: error: reinterpret_cast from integer to pointer reinterpret_cast(0x1234); Problem was observed while building for Yocto with generic toolchain: i586-poky-linux-g++ (GCC) 6.2.0 For reference see p125 of: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf Change-Id: I20b21ad1bdac40c2aec44706501343ae1d9d7b69 Bug: https://jira.iotivity.org/browse/IOT-1111 Origin: https://github.com/tizenteam/meta-oic Signed-off-by: Philippe Coval Reviewed-on: https://gerrit.iotivity.org/gerrit/11663 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../src/serverBuilder/unittests/RCSResourceObjectTest.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp b/service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp index 3126912..8aa958d 100644 --- a/service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp +++ b/service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp @@ -364,10 +364,8 @@ class ResourceObjectHandlingRequestTest: public ResourceObjectTest public: EntityHandler handler; - static constexpr OCRequestHandle fakeRequestHandle = - reinterpret_cast(0x1234); - static constexpr OCResourceHandle fakeResourceHandle = - reinterpret_cast(0x4321); + static const OCRequestHandle fakeRequestHandle; + static const OCResourceHandle fakeResourceHandle; public: OCResourceRequest::Ptr createRequest(OCMethod method = OC_REST_GET, OCRepresentation ocRep = @@ -415,6 +413,11 @@ protected: } }; +const OCRequestHandle ResourceObjectHandlingRequestTest::fakeRequestHandle = + reinterpret_cast(0x1234); +const OCResourceHandle ResourceObjectHandlingRequestTest::fakeResourceHandle = + reinterpret_cast(0x4321); + TEST_F(ResourceObjectHandlingRequestTest, CallSendResponseWhenReceiveRequest) { mocks.ExpectCallFunc(OCPlatform::sendResponse).Return(OC_STACK_OK); -- 2.7.4