I get this warning and I can't seem to figure out what it is referring too (it repeats this exact one ALOT when i have very little code). I'm trying to implement boost archive into my project as it allows less code to be written when serializing classes.

c:\program files (x86)\boost\boost_1_47\boost\archive\detail\interface_iarchive.hpp(60) : see reference to function template instantiation 'void boost::archive::binary_iarchive_impl<Archive,Elem,Tr>::load_override<T>(T &,int)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::binary_iarchive,
1>              Elem=char,
1>              Tr=std::char_traits<char>,
1>              T=boost::archive::object_id_type
1>          ]

You didn't even print the warning message.

My bad half asleep.

error

1>c:\program files (x86)\boost\boost_1_47\boost\archive\basic_binary_iprimitive.hpp(181): warning C4244: 
argument' : conversion from 'std::streamsize' to 'size_t', possible loss of data
1>          c:\program files (x86)\boost\boost_1_47\boost\archive\basic_binary_iprimitive.hpp(152) : while compiling class template member function 'void boost::archive::basic_binary_iprimitive<Archive,Elem,Tr>::load_binary(void *,size_t)'
1>          with
1>          [
1>              Archive=boost::archive::naked_binary_iarchive,
1>              Elem=char,
1>              Tr=std::char_traits<char>
1>          ]
1>          c:\program files (x86)\boost\boost_1_47\boost\archive\detail\iserializer.hpp(362) : see reference to function template instantiation 'void boost::archive::load_access::load_primitive<Archive,T>(Archive &,T &)' being compiled
1>          with
1>          [
1>              Archive=boost::archive::naked_binary_iarchive,
1>              T=boost::archive::object_id_type
1>          ]
//Lots more but it's just going through a bunch of templates

It's a type conversion but the ONLY code that contains boost is this little class I'm playing around with to get used to luabind and boost functions.

Header file where I declare serialization

#pragma once
#include <fstream>
#include <string>
#include <boost/function.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include "LuaHeaders.h"
class NPC
{
protected:
	friend class boost::serialization::access;

	template<class Archive>
	void serialize(Archive & ar, const unsigned int version)
	{
		ar & m_Name;
		ar & m_maxhealth;
		ar & m_health;
		ar & m_maxmana;
		ar & m_mana;
		ar & m_attack;
		ar & m_defense;
		ar & m_speed;
	}
public:
	std::string m_Name;
	int m_maxhealth;
	int m_health;
	int m_maxmana;
	int m_mana;
	int m_attack;
	int m_defense;
	float m_speed;
	float mx;
	float my;
	float mz;

	boost::function<void( float x, float y)> move;
	boost::function<const char*()> tostring;
	void translate(float x, float y, float z)
	{
		mx += x;
		my += y;
		mz += z;
	}
	void save(const char* path);
	NPC* load(const char* path);
	static void lua_init(lua_State* L);
	NPC(const char* name);
	NPC(const char* name, int maxhealth, int maxmana, int attack, int defense,float speed);
	NPC(void);
	virtual ~NPC(void);
};

CPP file. commented out stuff is normally enabled but I commented out to check if that was where the error was. The only place than the error seems to be able to be is in the header construction.

#include "NPC.h"

void NPC::save(const char* path)
{
	/*
	std::ofstream ofs(path);
	boost::archive::binary_oarchive oa(ofs);
	oa << this;
	ofs.close();
	*/
}

NPC* NPC::load(const char* path)
{
	if(path == nullptr)
		return nullptr;
	/*
	std::ifstream ifs(path);
	boost::archive::binary_iarchive ia(ifs);
	NPC* n = new NPC;
	ia >> n;
	ifs.close();

	return n;
	*/
	return nullptr;
}

void NPC::lua_init(lua_State* L)
{
		luabind::module(L)[luabind::class_<NPC>("NPC").def(luabind::constructor<const char*,int,int,int,int,float>())
		.def_readwrite("m_Name",&NPC::m_Name).def_readwrite("m_maxhealth",&NPC::m_maxhealth).def_readwrite("m_health",&NPC::m_health)
		.def_readwrite("m_maxmana",&NPC::m_maxmana).def_readwrite("m_mana",&NPC::m_mana).def_readwrite("m_attack",&NPC::m_attack)
		.def_readwrite("m_defense",&NPC::m_defense).def_readwrite("m_speed",&NPC::m_speed).def_readwrite("mx",&NPC::mx).def_readwrite("my",&NPC::my)
		.def_readwrite("mz",&NPC::mz).def("translate",(void(NPC::*)(float,float,float))&NPC::translate)
			];
}

NPC::NPC(const char* name) : m_Name(name)
{
	
}

NPC::NPC(const char* name,int maxhealth, int maxmana, int attack, int defense,float speed) : m_Name(name), m_maxhealth(maxhealth), m_health(maxhealth), m_maxmana(maxmana), m_mana(maxmana), m_attack(attack), m_defense(defense), m_speed(speed)
{
	mx = my = mz = 0.0f;
}

NPC::NPC(void)
{
}


NPC::~NPC(void)
{
	
}

Yuck. Not that it helps, but I've seen plenty of examples where warning 4244 is explicitly silenced in the build, rather than correcting the problem. :)

Unrelated, your "load" method should probably be declared "static" as a class-method instead of an instance-method.

> conversion from 'std::streamsize' to 'size_t', possible loss of data

Unless you are using files larger than 4GB in size on a 32-bit platform, you can safely ignore this warning.

Do you know how to silence it. I wouldn't mind if the warning wasn't nearly a hundred lines long making it ridiculous to look through the output window.

Place a #pragma warning(disable:4244) directive right at the top of the translation unit.

If you are using an earlier version of Microsoft C++, you could alternatively just turn off the (now deprecated) 64-bit portability warnings (/Wp64).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.