VectorNav C++ Library
compiler.h
1 #ifndef _VN_UTIL_COMPILER_H
2 #define _VN_UTIL_COMPILER_H
3 
4 // This header provides some simple checks for various features supported by the
5 // current compiler.
6 
7 // The VN_HAS_RANGE_LOOP define indicates if the compiler supports range based
8 // loops.
9 //
10 // for (auto i : _items)
11 // cout << i << endl;
12 //
13 // HACK: Currently not checking the compiler and defaulting to no range loop support.
14 #define VN_HAS_RANGE_LOOP 0
15 
16 // The VN_SUPPORTS_SWAP define indicates if the compiler supports the swap
17 // operation for STL items.
18 //
19 // [Example]
20 //
21 // #if VN_SUPPORTS_SWAP
22 // queue<Packet> empty;
23 // _receivedResponses.swap(empty);
24 // #else
25 // while (!_receivedResponses.empty()) _receivedResponses.pop();
26 // #endif
27 //
28 #if (defined(_MSC_VER) && _MSC_VER > 1500) || (__cplusplus >= 201103L)
29  #define VN_SUPPORTS_SWAP 1
30 #else
31  #define VN_SUPPORTS_SWAP 0
32 #endif
33 
34 // The VN_SUPPORTS_INITIALIZER_LIST define indicates if the compiler supports
35 // using an initialization list to initialize STL containers.
36 //
37 // [Example]
38 //
39 // #if VN_SUPPORTS_INITIALIZER_LIST
40 // vector<CompositeData*> d({ &ez->_persistentData, &nd });
41 // #else
42 // vector<CompositeData*> d(2);
43 // d[0] = &ez->_persistentData;
44 // d[1] = &nd;
45 // #endif
46 //
47 #if (defined(_MSC_VER) && _MSC_VER <= 1600) || (__cplusplus < 201103L)
48  #define VN_SUPPORTS_INITIALIZER_LIST 0
49 #else
50  #define VN_SUPPORTS_INITIALIZER_LIST 1
51 #endif
52 
53 // The VN_SUPPORTS_CSTR_STRING_CONCATENATE define indictes if the compiler supports
54 // concatenating a C-style string with std::string using the '+' operator.
55 //
56 // [Example]
57 //
58 // #if VN_SUPPORTS_CSTR_STRING_CONCATENATE
59 // explicit permission_denied(std::string itemName) : runtime_error(std::string("Permission denied for item '" + itemName + "'.").c_str()) { }
60 // #else
61 // explicit permission_denied(std::string itemName) : runtime_error("Permission denied for item.") { }
62 // #endif
63 //
64 #if (defined(_MSC_VER) && _MSC_VER <= 1600)
65  #define VN_SUPPORTS_CSTR_STRING_CONCATENATE 0
66 #else
67  #define VN_SUPPORTS_CSTR_STRING_CONCATENATE 1
68 #endif
69 
70 // Determine if the secure CRT and SCL are available.
71 #if defined(_MSC_VER)
72  #define VN_HAVE_SECURE_CRT 1
73  #define VN_HAVE_SECURE_SCL 1
74 #else
75  #define VN_HAVE_SECURE_CRT 0
76  #define VN_HAVE_SECURE_SCL 0
77 #endif
78 
79 #endif