Removed C++11 specific code from the CSDK, added platform_features
authorErich Keane <erich.keane@intel.com>
Fri, 31 Jul 2015 23:14:41 +0000 (16:14 -0700)
committerJon A. Cruz <jonc@osg.samsung.com>
Sun, 2 Aug 2015 02:25:17 +0000 (02:25 +0000)
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 <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2036
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
android/android_api/base/jni/Android.mk
resource/c_common/SConscript
resource/c_common/platform_features.h [new file with mode: 0644]
resource/csdk/stack/include/octypes.h

index be7e3ca..f29d75a 100644 (file)
@@ -72,6 +72,7 @@ LOCAL_STATIC_LIBRARIES += android_cpp11_compat
 LOCAL_CPPFLAGS += -std=c++0x\r
 LOCAL_CPP_FEATURES := rtti exceptions\r
 LOCAL_C_INCLUDES := $(OIC_SRC_PATH)/include\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/c_common\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/stack/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include\r
index f0e140c..d018d88 100644 (file)
@@ -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 (file)
index 0000000..2fdaded
--- /dev/null
@@ -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
index 12e600d..5f602ff 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef OCTYPES_H_
 #define OCTYPES_H_
 
+#include "platform_features.h"
 #include "ocstackconfig.h"
 #include <stdbool.h>
 #include <stdint.h>
@@ -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){}