Skip to content

Commit

Permalink
more modern and more warnings (#13)
Browse files Browse the repository at this point in the history
build with msvc-14, silence boost warnings, build with all warnings and warnings as errors, move towards cleaner c++11
  • Loading branch information
arvidn committed Jun 14, 2016
1 parent f0e4243 commit d8b5afd
Show file tree
Hide file tree
Showing 31 changed files with 502 additions and 243 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ install:
- ccache -V && ccache --show-stats && ccache --zero-stats

script:
- bjam --hash -j3 variant=$variant -l900 $toolset $target
- bjam --hash -j3 variant=$variant -l900 warnings-as-errors=on $toolset $target
- ccache --show-stats

5 changes: 5 additions & 0 deletions Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ lib simulator
<target-os>windows:<library>wsock32

<link>shared:<define>SIMULATOR_BUILDING_SHARED
<define>_CRT_SECURE_NO_WARNINGS

# disable auto-link
<define>BOOST_ALL_NO_LIB

<toolset>gcc:<cxxflags>-std=c++11

: # default build
<warnings>all
<warnings-as-errors>on

: # usage requirements
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME
Expand All @@ -90,6 +93,8 @@ lib simulator
project
: requirements
<library>simulator
# disable auto-link
<define>BOOST_ALL_NO_LIB
: default-build
<link>static
;
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip_tags: true
clone_depth: 1
install:
- set BUILD_DIR=%CD%
- set BOOST_ROOT=c:\Libraries\boost
- set BOOST_ROOT=c:\Libraries\boost_1_59_0
- set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build
- echo %BOOST_ROOT%
- echo %BOOST_BUILD_PATH%
Expand All @@ -16,7 +16,7 @@ install:
- cd %BUILD_DIR%
environment:
matrix:
- compiler: msvc-12.0
- compiler: msvc-14.0
- compiler: gcc
build_script:
- b2.exe --hash -j2 address-model=32 %compiler%
Expand Down
15 changes: 14 additions & 1 deletion include/simulator/http_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ All rights reserved.
*/

#ifndef HTTP_PROXY_HPP_INCLUDED
#define HTTP_PROXY_HPP_INCLUDED

#include "simulator/simulator.hpp"

#ifdef _MSC_VER
#pragma warning(push)
// warning C4251: X: class Y needs to have dll-interface to be used by clients of struct
#pragma warning( disable : 4251)
#endif

namespace sim
{
struct http_request;
Expand All @@ -26,7 +35,7 @@ namespace sim
// concurrent connection
struct SIMULATOR_DECL http_proxy
{
http_proxy(asio::io_service& ios, int listen_port);
http_proxy(asio::io_service& ios, unsigned short listen_port);

void stop();

Expand Down Expand Up @@ -86,5 +95,9 @@ struct SIMULATOR_DECL http_proxy

}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif

16 changes: 15 additions & 1 deletion include/simulator/http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ All rights reserved.
*/

#ifndef HTTP_SERVER_HPP_INCLUDED
#define HTTP_SERVER_HPP_INCLUDED

#include "simulator/simulator.hpp"
#include <string>

#ifdef _MSC_VER
#pragma warning(push)
// warning C4251: X: class Y needs to have dll-interface to be used by clients of struct
#pragma warning( disable : 4251)
#endif

namespace sim
{
std::string SIMULATOR_DECL trim(std::string s);
Expand Down Expand Up @@ -54,7 +63,7 @@ struct SIMULATOR_DECL http_server
keep_alive = 1
};

http_server(asio::io_service& ios, int listen_port
http_server(asio::io_service& ios, unsigned short listen_port
, int flags = http_server::keep_alive);

void stop();
Expand Down Expand Up @@ -98,4 +107,9 @@ struct SIMULATOR_DECL http_server

}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif

44 changes: 44 additions & 0 deletions include/simulator/pop_warnings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright (c) 2015, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#ifdef __clang__
#pragma clang diagnostic pop
#endif

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

89 changes: 89 additions & 0 deletions include/simulator/push_warnings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright (c) 2015, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wswitch-enum"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wundef"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wpedantic"
#if __GNUC__ >= 6
#pragma GCC diagnostic ignored "-Wshift-overflow"
#pragma GCC diagnostic ignored "-Wshift-count-overflow"
#pragma GCC diagnostic ignored "-Wshift-count-negative"
#endif
#endif

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#pragma clang diagnostic ignored "-Weverything"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wswitch-enum"
#pragma clang diagnostic ignored "-Wcovered-switch-default"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wweak-vtables"
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#pragma clang diagnostic ignored "-Wdeprecated"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wcast-align"
#pragma clang diagnostic ignored "-Wweak-vtable"
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wshadow"
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#pragma clang diagnostic ignored "-Wc++11-long-long"
#pragma clang diagnostic ignored "-Wc++11-extensions"
#pragma clang diagnostic ignored "-Wextra-semi"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#pragma clang diagnostic ignored "-Wunused-local-typedef"
#pragma clang diagnostic ignored "-Wgnu-folding-constant"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wfloat-equal"
#endif

#ifdef _MSC_VER
#pragma warning(push, 1)
// warning C4005: macro redefinition
#pragma warning( disable : 4005 )
#endif

10 changes: 10 additions & 0 deletions include/simulator/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ All rights reserved.

#include "simulator/simulator.hpp"

#ifdef _MSC_VER
#pragma warning(push)
// warning C4251: X: class Y needs to have dll-interface to be used by clients of struct
#pragma warning( disable : 4251)
#endif

namespace sim
{

Expand Down Expand Up @@ -66,5 +72,9 @@ namespace sim

}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif

Loading

0 comments on commit d8b5afd

Please sign in to comment.