From 7a995b5ca72992e2daf427400f0bbde551f6d682 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 31 Jul 2015 16:14:41 -0700 Subject: [PATCH] Removed C++11 specific code from the CSDK, added platform_features The CSDK provides some nice-to-have Constructors when compiling some POD types. The code erronously used C++11's 'default' keyword, which isn't available on older compilers. Since C++11/0x is not a requirement for the CSDK, this disables the constructors in the case where C++11/0x is not enabled. In order to do this, it adds a platform_features.h, which should be used to selectively compile things based on features (rather than based on the platform name itself) Change-Id: Ie8b9a5e9b5d6424fd8a1f37cfdbd587f665c2638 Signed-off-by: Erich Keane Reviewed-on: https://gerrit.iotivity.org/gerrit/2036 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- android/android_api/base/jni/Android.mk | 1 + resource/c_common/SConscript | 1 + resource/c_common/platform_features.h | 37 +++++++++++++++++++++++++++++++++ resource/csdk/stack/include/octypes.h | 5 +++-- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 resource/c_common/platform_features.h diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk index be7e3ca..f29d75a 100644 --- a/android/android_api/base/jni/Android.mk +++ b/android/android_api/base/jni/Android.mk @@ -72,6 +72,7 @@ LOCAL_STATIC_LIBRARIES += android_cpp11_compat LOCAL_CPPFLAGS += -std=c++0x LOCAL_CPP_FEATURES := rtti exceptions LOCAL_C_INCLUDES := $(OIC_SRC_PATH)/include +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/stack/include LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include diff --git a/resource/c_common/SConscript b/resource/c_common/SConscript index f0e140c..d018d88 100644 --- a/resource/c_common/SConscript +++ b/resource/c_common/SConscript @@ -23,6 +23,7 @@ Import('env') import os env.AppendUnique(CPPPATH = [ + os.path.join(Dir('.').abspath), os.path.join(Dir('.').abspath, 'oic_malloc/include'), os.path.join(Dir('.').abspath, 'oic_string/include') ]) diff --git a/resource/c_common/platform_features.h b/resource/c_common/platform_features.h new file mode 100644 index 0000000..2fdaded --- /dev/null +++ b/resource/c_common/platform_features.h @@ -0,0 +1,37 @@ +//****************************************************************** +// +// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//****************************************************************** + +/** + * @file + * + * This file contains compiler and platform feature definitions. These + * can be used to enable functionality on only platforms that support + * said functionality. + */ + +#ifndef PLATFORM_FEATURES_H_ +#define PLATFORM_FEATURES_H_ + + +#if (__cplusplus >=201103L) || defined(__GXX_EXPERIMENTAL_CXX0X__) + #define SUPPORTS_DEFAULT_CTOR +#endif + +#endif diff --git a/resource/csdk/stack/include/octypes.h b/resource/csdk/stack/include/octypes.h index 12e600d..5f602ff 100644 --- a/resource/csdk/stack/include/octypes.h +++ b/resource/csdk/stack/include/octypes.h @@ -28,6 +28,7 @@ #ifndef OCTYPES_H_ #define OCTYPES_H_ +#include "platform_features.h" #include "ocstackconfig.h" #include #include @@ -751,7 +752,7 @@ typedef struct OCHeaderOption /** pointer to its data.*/ uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH]; -#ifdef __cplusplus +#ifdef SUPPORTS_DEFAULT_CTOR OCHeaderOption() = default; OCHeaderOption(OCTransportProtocolID pid, uint16_t optId, @@ -1131,7 +1132,7 @@ typedef struct OCCallbackData /** A pointer to a function to delete the context when this callback is removed.*/ OCClientContextDeleter cd; -#ifdef __cplusplus +#ifdef SUPPORTS_DEFAULT_CTOR OCCallbackData() = default; OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter) :context(ctx), cb(callback), cd(deleter){} -- 2.7.4