From fce9ad4e1b45aa3dc9490de5d9e8ef6a9a0ac3f3 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 9 Nov 2009 12:27:54 +0000 Subject: [PATCH] Misc small fixes to suppress warnings. Code should now be clean with msvc /W4 and gcc /Wall /Wextra -pedantic with the exception of one deliberate warning in one test. [SVN r57510] --- lexical_cast_test.cpp | 7 +++++++ numeric_cast_test.cpp | 2 +- test/implicit_cast.cpp | 6 ++++++ test/implicit_cast_fail.cpp | 2 ++ test/lexical_cast_abstract_test.cpp | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 12e9deb..a994d13 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -11,6 +11,13 @@ // // Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. +// +// We need this #define before any #includes: otherwise msvc will emit warnings +// deep within std::string, resulting from our (perfectly legal) use of basic_string +// with a custom traits class: +// +#define _SCL_SECURE_NO_WARNINGS + #include #if defined(__INTEL_COMPILER) diff --git a/numeric_cast_test.cpp b/numeric_cast_test.cpp index 0b5bcde..51393b9 100644 --- a/numeric_cast_test.cpp +++ b/numeric_cast_test.cpp @@ -28,7 +28,7 @@ using namespace boost; using std::cout; -int test_main( int argc, char * argv[] ) +int test_main( int , char * [] ) { # ifdef NDEBUG diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index e18e17a..8c3bc52 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -28,5 +28,11 @@ int main() type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); + + // warning supression: + (void)x; + (void)f; + (void)z; + return boost::report_errors(); } diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp index 80143da..a7867a1 100644 --- a/test/implicit_cast_fail.cpp +++ b/test/implicit_cast_fail.cpp @@ -19,4 +19,6 @@ struct foo int test_main(int, char*[]) { foo x = implicit_cast("foobar"); + (void)x; // warning suppression. + return 0; } diff --git a/test/lexical_cast_abstract_test.cpp b/test/lexical_cast_abstract_test.cpp index 207d3a5..4b92e49 100644 --- a/test/lexical_cast_abstract_test.cpp +++ b/test/lexical_cast_abstract_test.cpp @@ -51,7 +51,7 @@ std::ostream &operator<<(std::ostream &O, const A &a) { a.out(O); return O; -}; +} void test_abstract() {