Skip to content

Commit

Permalink
Various fixes for warning level 4 with MSVC
Browse files Browse the repository at this point in the history
closes #178
relates #151
  • Loading branch information
AzothAmmo committed Mar 29, 2015
1 parent af9454b commit 14bc429
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/cereal/archives/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ namespace cereal
{
search();

val = itsIteratorStack.back().value().GetInt();
val = static_cast<T>( itsIteratorStack.back().value().GetInt() );
++itsIteratorStack.back();
}

Expand All @@ -585,7 +585,7 @@ namespace cereal
{
search();

val = itsIteratorStack.back().value().GetUint();
val = static_cast<T>( itsIteratorStack.back().value().GetUint() );
++itsIteratorStack.back();
}

Expand Down
4 changes: 2 additions & 2 deletions include/cereal/archives/xml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ namespace cereal
//! Load an int8_t from the current top node (ensures we parse entire number)
void loadValue( int8_t & value )
{
int32_t val; loadValue( val ); value = val;
int32_t val; loadValue( val ); value = static_cast<int8_t>( val );
}

//! Load a uint8_t from the current top node (ensures we parse entire number)
void loadValue( uint8_t & value )
{
uint32_t val; loadValue( val ); value = val;
uint32_t val; loadValue( val ); value = static_cast<uint8_t>( val );
}

//! Loads a type best represented as an unsigned long from the current top node
Expand Down
4 changes: 4 additions & 0 deletions include/cereal/cereal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ namespace cereal
OutputArchive(ArchiveType * const derived) : self(derived), itsCurrentPointerId(1), itsCurrentPolymorphicTypeId(1)
{ }

OutputArchive & operator=( OutputArchive const & ) = delete;

//! Serializes all passed in data
/*! This is the primary interface for serializing data with an archive */
template <class ... Types> inline
Expand Down Expand Up @@ -586,6 +588,8 @@ namespace cereal
itsPolymorphicTypeMap(),
itsVersionedTypes()
{ }

InputArchive & operator=( InputArchive const & ) = delete;

//! Serializes all passed in data
/*! This is the primary interface for serializing data with an archive */
Expand Down
6 changes: 6 additions & 0 deletions include/cereal/details/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ namespace cereal
static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
"Cannot pair a name to a NameValuePair" );

NameValuePair & operator=( NameValuePair const & ) = delete;

public:
//! Constructs a new NameValuePair
/*! @param n The name of the pair
Expand Down Expand Up @@ -254,6 +256,8 @@ namespace cereal
T,
typename std::decay<T>::type>::type;

SizeTag & operator=( SizeTag const & ) = delete;

public:
SizeTag( T && sz ) : size(std::forward<T>(sz)) {}

Expand Down Expand Up @@ -298,6 +302,8 @@ namespace cereal
/*! @internal */
MapItem( Key && key_, Value && value_ ) : key(std::forward<Key>(key_)), value(std::forward<Value>(value_)) {}

MapItem & operator=( MapItem const & ) = delete;

KeyType key;
ValueType value;

Expand Down
11 changes: 11 additions & 0 deletions include/cereal/external/rapidjson/genericstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#include "rapidjson.h"
#include <iostream>

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 4512) // assignment operator could not be generated
#pragma warning(disable: 4100) // unreferenced formal parameter
#endif

namespace rapidjson {

//! Wrapper of std::istream for input.
Expand Down Expand Up @@ -91,4 +98,8 @@ namespace rapidjson {

} // namespace rapidjson

// On MSVC, restore warnings state
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // RAPIDJSON_GENERICSTREAM_H_
1 change: 1 addition & 0 deletions include/cereal/external/rapidjson/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
#pragma warning(disable : 4702) // uncreachable code
#endif

#ifndef RAPIDJSON_PARSE_ERROR
Expand Down
1 change: 1 addition & 0 deletions include/cereal/external/rapidxml/rapidxml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4127) // Conditional expression is constant
#pragma warning(disable:4100) // unreferenced formal parameter
#endif

///////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions include/cereal/types/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace cereal
{
PtrWrapper(T && p) : ptr(std::forward<T>(p)) {}
T & ptr;

PtrWrapper & operator=( PtrWrapper const & ) = delete;
};

//! Make a PtrWrapper
Expand Down
2 changes: 2 additions & 0 deletions unittests/user_data_adapters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct UserStruct
ref( reference )
{ }

UserStruct & operator=( UserStruct const & ) = delete;

std::int32_t i32;
SomeStruct const * p;
SomeStruct & ref;
Expand Down
9 changes: 5 additions & 4 deletions vs2013/sandbox_vs/sandbox_vs.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<TreatWarningAsError>false</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -94,7 +95,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
Expand All @@ -105,7 +106,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand All @@ -120,7 +121,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand Down
4 changes: 2 additions & 2 deletions vs2013/unittests/unittests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
Expand Down Expand Up @@ -168,7 +168,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand Down

0 comments on commit 14bc429

Please sign in to comment.