Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/serialization/static_warning.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 #ifndef BOOST_SERIALIZATION_STATIC_WARNING_HPP | |
2 #define BOOST_SERIALIZATION_STATIC_WARNING_HPP | |
3 | |
4 // (C) Copyright Robert Ramey 2003. Jonathan Turkanis 2004. | |
5 // Use, modification and distribution is subject to the Boost Software | |
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 // MS compatible compilers support #pragma once | |
8 #if defined(_MSC_VER) && (_MSC_VER >= 1020) | |
9 # pragma once | |
10 #endif | |
11 | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 // See http://www.boost.org/libs/static_assert for documentation. | |
15 | |
16 /* | |
17 Revision history: | |
18 15 June 2003 - Initial version. | |
19 31 March 2004 - improved diagnostic messages and portability | |
20 (Jonathan Turkanis) | |
21 03 April 2004 - works on VC6 at class and namespace scope | |
22 - ported to DigitalMars | |
23 - static warnings disabled by default; when enabled, | |
24 uses pragmas to enable required compiler warnings | |
25 on MSVC, Intel, Metrowerks and Borland 5.x. | |
26 (Jonathan Turkanis) | |
27 30 May 2004 - tweaked for msvc 7.1 and gcc 3.3 | |
28 - static warnings ENabled by default; when enabled, | |
29 (Robert Ramey) | |
30 */ | |
31 | |
32 #include <boost/config.hpp> | |
33 | |
34 // | |
35 // Implementation | |
36 // Makes use of the following warnings: | |
37 // 1. GCC prior to 3.3: division by zero. | |
38 // 2. BCC 6.0 preview: unreferenced local variable. | |
39 // 3. DigitalMars: returning address of local automatic variable. | |
40 // 4. VC6: class previously seen as struct (as in 'boost/mpl/print.hpp') | |
41 // 5. All others: deletion of pointer to incomplete type. | |
42 // | |
43 // The trick is to find code which produces warnings containing the name of | |
44 // a structure or variable. Details, with same numbering as above: | |
45 // 1. static_warning_impl<B>::value is zero iff B is false, so diving an int | |
46 // by this value generates a warning iff B is false. | |
47 // 2. static_warning_impl<B>::type has a constructor iff B is true, so an | |
48 // unreferenced variable of this type generates a warning iff B is false. | |
49 // 3. static_warning_impl<B>::type overloads operator& to return a dynamically | |
50 // allocated int pointer only is B is true, so returning the address of an | |
51 // automatic variable of this type generates a warning iff B is fasle. | |
52 // 4. static_warning_impl<B>::STATIC_WARNING is decalred as a struct iff B is | |
53 // false. | |
54 // 5. static_warning_impl<B>::type is incomplete iff B is false, so deleting a | |
55 // pointer to this type generates a warning iff B is false. | |
56 // | |
57 | |
58 //------------------Enable selected warnings----------------------------------// | |
59 | |
60 // Enable the warnings relied on by BOOST_STATIC_WARNING, where possible. The | |
61 // only pragma which is absolutely necessary here is for Borland 5.x, since | |
62 // W8073 is disabled by default. If enabling selected warnings is considered | |
63 // unacceptable, this section can be replaced with: | |
64 // #if defined(__BORLANDC__) && (__BORLANDC__ <= 0x600) | |
65 // pragma warn +st | |
66 // #endif | |
67 | |
68 // 6. replaced implementation with one which depends solely on | |
69 // mpl::print<>. The previous one was found to fail for functions | |
70 // under recent versions of gcc and intel compilers - Robert Ramey | |
71 | |
72 #include <boost/mpl/bool.hpp> | |
73 #include <boost/mpl/print.hpp> | |
74 #include <boost/mpl/eval_if.hpp> | |
75 | |
76 namespace boost { | |
77 namespace serialization { | |
78 | |
79 template<int L> | |
80 struct BOOST_SERIALIZATION_STATIC_WARNING_LINE{}; | |
81 | |
82 template<bool B, int L> | |
83 struct static_warning_test{ | |
84 typename boost::mpl::eval_if_c< | |
85 B, | |
86 boost::mpl::true_, | |
87 typename boost::mpl::identity< | |
88 boost::mpl::print< | |
89 BOOST_SERIALIZATION_STATIC_WARNING_LINE<L> | |
90 > | |
91 > | |
92 >::type type; | |
93 }; | |
94 | |
95 template<int i> | |
96 struct BOOST_SERIALIZATION_SS {}; | |
97 | |
98 } // serialization | |
99 } // boost | |
100 | |
101 #define BOOST_SERIALIZATION_BSW(B, L) \ | |
102 typedef boost::serialization::BOOST_SERIALIZATION_SS< \ | |
103 sizeof( boost::serialization::static_warning_test< B, L > ) \ | |
104 > BOOST_JOIN(STATIC_WARNING_LINE, L); | |
105 | |
106 #define BOOST_STATIC_WARNING(B) BOOST_SERIALIZATION_BSW(B, __LINE__) | |
107 | |
108 #endif // BOOST_SERIALIZATION_STATIC_WARNING_HPP |