Overte C++ Documentation
windowshacks.h
1 //
2 // windowshacks.h
3 // interface/src
4 //
5 // Created by Brad Hefta-Gaub on 1/12/14.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // hacks to get windows to compile
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 //
13 
14 #ifndef hifi_windowshacks_h
15 #define hifi_windowshacks_h
16 
17 #ifdef WIN32
18 
19 #include <cmath>
20 inline double roundf(double value) {
21  return (value > 0.0) ? floor(value + 0.5) : ceil(value - 0.5);
22 }
23 #define round roundf
24 
25 #ifdef _MSC_VER
26 #ifndef SNPRINTF_FIX
27 #define SNPRINTF_FIX
28 #include <stdio.h>
29 #include <stdarg.h>
30 
31 #define snprintf c99_snprintf
32 
33 inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
34  int count = -1;
35  if (size != 0) {
36  count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
37  }
38  if (count == -1) {
39  count = _vscprintf(format, ap);
40  }
41  return count;
42 }
43 
44 inline int c99_snprintf(char* str, size_t size, const char* format, ...) {
45  int count;
46  va_list ap;
47 
48  va_start(ap, format);
49  count = c99_vsnprintf(str, size, format, ap);
50  va_end(ap);
51 
52  return count;
53 }
54 #endif // SNPRINTF_FIX
55 #endif // _MSC_VER
56 
57 #include <winsock2.h>
58 #include <WS2tcpip.h>
59 
60 #else // WIN32
61 
62 #include <netinet/in.h>
63 
64 #endif // WIN32
65 
66 #endif // hifi_windowshacks_h