VS 2013 fixes
authorDave Thaler <dthaler@microsoft.com>
Thu, 2 Jun 2016 18:26:55 +0000 (11:26 -0700)
committerDavid Antler <david.a.antler@intel.com>
Mon, 6 Jun 2016 16:37:39 +0000 (16:37 +0000)
Change-Id: Ic3a398995bb558b6e0b8fb01fcbfed6098f757d7
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8443
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: David Antler <david.a.antler@intel.com>
18 files changed:
build_common/windows/SConscript
extlibs/tinydtls/dtls_config.h
resource/c_common/ocrandom/src/ocrandom.c
resource/c_common/platform_features.h
resource/c_common/windows/src/snprintf.c
resource/csdk/connectivity/lib/libcoap-4.1.1/debug.c
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.c
resource/csdk/connectivity/src/ip_adapter/SConscript
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/test/ca_api_unittest.cpp
resource/csdk/logger/SConscript
resource/csdk/logger/src/logger.c
resource/csdk/security/provisioning/SConscript
resource/csdk/security/provisioning/src/pmutility.c
resource/csdk/security/src/secureresourcemanager.c
resource/include/AttributeValue.h
resource/src/OCRepresentation.cpp
service/things-manager/sdk/inc/ActionSet.h

index 305487a..bf57dee 100644 (file)
@@ -18,6 +18,8 @@ if env['CC'] == 'cl':
        env.AppendUnique(CXXFLAGS=['/wd4244', '/wd4267', '/wd4355', '/wd4800', '/wd4996', '/wd4820', '/wd4514', '/wd4365', '/wd4503'])
        env.AppendUnique(CCFLAGS=['/EHsc'])
 
+       vs_version = env['MSVC_VERSION']
+
        # Enable special exports for unit test purposes
        if env.get('TEST') == '1':
                env.AppendUnique(CPPDEFINES = ['ENABLE_TEST_EXPORTS'])
@@ -25,9 +27,12 @@ if env['CC'] == 'cl':
        if env.get('RELEASE'):
                env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF'])
                env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-       else:
+       elif env.get('TARGET_ARCH') in ['x86', 'x86_64'] or "14.0" in vs_version:
                env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/ZI', '/RTC1', '/Gm'])
                env.AppendUnique(LINKFLAGS = ['/debug'])
+       else:
+               env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/Zi', '/RTC1', '/Gm'])
+               env.AppendUnique(LINKFLAGS = ['/debug'])
        env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
        env.AppendUnique(PATH = os.environ['PATH'])
 
index 6137c29..5e0103a 100644 (file)
 /* #undef size_t */
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 #define ssize_t SSIZE_T
-#define snprintf _snprintf
+#define snprintf vs12_snprintf
 #endif
 #if defined(_WIN32)
 #define MSG_DONTWAIT 0
index cea769f..118aeee 100644 (file)
@@ -30,6 +30,7 @@
 #define _POSIX_C_SOURCE 200809L
 #endif
 
+#include "platform_features.h"
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
index 762d26e..680f367 100644 (file)
@@ -81,7 +81,7 @@
 #  define strncasecmp _strnicmp
 #  define strtok_r strtok_s
 #  if _MSC_VER && (_MSC_VER < 1900)
-#    include "vs12_snprintf.h"
+#    include "windows/include/vs12_snprintf.h"
 #  endif
 #  define ssize_t SSIZE_T
 #  define F_OK                0
@@ -89,8 +89,8 @@
 #  ifdef __cplusplus
 #    define SUPPORTS_DEFAULT_CTOR
 #  endif
-#  include "win_sleep.h"
-#  include "pthread_create.h"
+#  include "windows/include/win_sleep.h"
+#  include "windows/include/pthread_create.h"
 #endif
 
 #ifdef HAVE_WINSOCK2_H
index 87a9242..01e4f16 100644 (file)
@@ -28,7 +28,7 @@ int vs12_snprintf(char *buffer, size_t count, const char *format, ...)
 
     va_start(args, format);
 
-    length = _snprintf(buffer, count, format, args);
+    length = _vsnprintf(buffer, count, format, args);
 
     va_end(args);
 
index 589e1c3..fc4f1da 100644 (file)
@@ -196,7 +196,11 @@ size_t coap_print_addr(const struct coap_address_t *addr, unsigned char *buf, si
             return 0;
     }
 
+#ifdef HAVE_SNPRINTF
     p += snprintf((char *) p, buf + len - p + 1, ":%d", port);
+#else /* HAVE_SNPRINTF */
+    /* @todo manual conversion of port number */
+#endif /* HAVE_SNPRINTF */
 
     return buf + len - p;
 #else /* HAVE_ARPA_INET_H */
index 54776af..3af2f0c 100644 (file)
@@ -64,7 +64,9 @@ coap_free_subscription(coap_subscription_t *subscription)
 }
 #endif /* WITH_CONTIKI */
 
+#ifndef min
 #define min(a,b) ((a) < (b) ? (a) : (b))
+#endif
 
 /* Helper functions for conditional output of character sequences into
  * a given buffer. The first Offset characters are skipped.
index 4d45917..8706ecf 100644 (file)
@@ -48,7 +48,7 @@ if target_os in ['linux','darwin','ios']:
     target_files += [ os.path.join(src_dir,
                                    'linux/caipnwmonitor.c') ]
 
-if target_os in ['windows', 'msys_nt']:
+if target_os in ['msys_nt']:
        target_files += [ os.path.join(src_dir, 'windows/caipnwmonitor.c') ]
 
 # The list of BLE adapter source files is a combination of both the
index 4b47876..6a9cb97 100644 (file)
@@ -713,7 +713,7 @@ static int CACreateSocket(int family, uint16_t *port)
     if (*port) // use the given port
     {
         int on = 1;
-        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)))
+        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, OPTVAL_T(&on), sizeof (on)))
         {
             OIC_LOG_V(ERROR, TAG, "SO_REUSEADDR failed: %s", CAIPS_GET_ERROR);
 #ifdef _WIN32
@@ -1024,7 +1024,7 @@ static void applyMulticastToInterface4(uint32_t ifindex)
             OIC_LOG_V(ERROR, TAG, "       IPv4 IP_ADD_MEMBERSHIP failed: %s", CAIPS_GET_ERROR);
         }
     }
-    ret = setsockopt(caglobals.ip.m4s.fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof (mreq));
+    ret = setsockopt(caglobals.ip.m4s.fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, OPTVAL_T(&mreq), sizeof (mreq));
     if (-1 == ret)
     {
 #if !defined(WSAEINVAL)
@@ -1042,7 +1042,7 @@ static void applyMulticast6(int fd, struct in6_addr *addr, uint32_t ifindex)
 {
     struct ipv6_mreq mreq = {.ipv6mr_multiaddr = *addr,
                              .ipv6mr_interface = ifindex };
-    int ret = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof (mreq));
+    int ret = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, OPTVAL_T(&mreq), sizeof (mreq));
     if (-1 == ret)
     {
 #if !defined(_WIN32)
index 940c838..e8c1986 100644 (file)
@@ -18,6 +18,7 @@
  *
  ******************************************************************/
 
+#include "platform_features.h"
 #include "gtest/gtest.h"
 #include "cainterface.h"
 #include "cautilinterface.h"
index cb82de4..b81fb7e 100644 (file)
@@ -1,7 +1,9 @@
 Import('env')
 import os
 
-env.AppendUnique(CPPPATH = [os.path.join(Dir('.').abspath, 'include')])
+env.AppendUnique(CPPPATH = [os.path.join(Dir('.').abspath, 'include'),
+                            '../../c_common'
+    ])
 
 if env.get('TARGET_OS') in ['arduino']:
        env.AppendUnique(CPPPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common/oic_string/include')])
index c2669c8..7a32b46 100644 (file)
 // clock_gettime() support.
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
-
-// if we have unistd.h, we're a Unix system
+#endif
 #include <time.h>
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-
 #ifdef HAVE_WINDOWS_H
 #include <windows.h>
 #endif
@@ -47,6 +46,7 @@
 #include "logger.h"
 #include "string.h"
 #include "logger_types.h"
+#include "platform_features.h"
 
 #ifndef __TIZEN__
 static oc_log_ctx_t *logCtx = 0;
index ce43e5a..21686b5 100644 (file)
@@ -58,7 +58,8 @@ if target_os != 'tizen':
        provisioning_env.AppendUnique(CPPPATH = ['../../../../extlibs/sqlite3'])
 
 provisioning_env.AppendUnique(CPPDEFINES= ['__WITH_DTLS__'])
-provisioning_env.AppendUnique(CFLAGS = ['-std=c99'])
+if target_os not in ['windows']:
+       provisioning_env.AppendUnique(CFLAGS = ['-std=c99'])
 if target_os not in ['windows', 'msys_nt']:
        provisioning_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
 
index c57b725..b52fe47 100644 (file)
@@ -476,8 +476,8 @@ uint16_t GetSecurePortFromJSON(char* jsonStr)
 }
 
 bool PMGenerateQuery(bool isSecure,
-                     const char* address, const uint16_t port,
-                     const OCConnectivityType connType,
+                     const char* address, uint16_t port,
+                     OCConnectivityType connType,
                      char* buffer, size_t bufferSize, const char* uri)
 {
     if(!address || !buffer || !uri)
index 93cfeba..10b46a8 100644 (file)
@@ -343,7 +343,7 @@ OCStackResult SRMInitPolicyEngine()
 
 void SRMDeInitPolicyEngine()
 {
-    return DeInitPolicyEngine(&g_policyEngineContext);
+    DeInitPolicyEngine(&g_policyEngineContext);
 }
 
 bool SRMIsSecurityResourceURI(const char* uri)
index d800070..5b9ca83 100644 (file)
@@ -136,7 +136,7 @@ namespace OC
     template<>
     struct AttributeTypeConvert<std::vector<uint8_t>>
     {
-        constexpr static AttributeType type = AttributeType::Binary;
+        BOOST_STATIC_CONSTEXPR AttributeType type = AttributeType::Binary;
     };
 
     std::ostream& operator << (std::ostream& os, const AttributeType at);
index d88d3f1..09d1e16 100644 (file)
@@ -926,9 +926,9 @@ namespace OC
     {
         typedef std::vector<uint8_t> type;
         typedef std::vector<uint8_t> base_type;
-        constexpr static AttributeType enum_type = AttributeType::Binary;
-        constexpr static AttributeType enum_base_type = AttributeType::Binary;
-        constexpr static size_t depth = 0;
+        BOOST_STATIC_CONSTEXPR AttributeType enum_type = AttributeType::Binary;
+        BOOST_STATIC_CONSTEXPR AttributeType enum_base_type = AttributeType::Binary;
+        BOOST_STATIC_CONSTEXPR size_t depth = 0;
     };
 
 
index 52a54a7..de8c2c3 100755 (executable)
 #include <vector>
 #include <cstdio>
 #include <iostream>
-
 #include <ctime>
-
 #include <timer.h>
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-/** @todo: Ensure null termination. This is not identical */
-#define snprintf _snprintf
-#endif
 
 using namespace std;