Re: serialization, size errors... or something else.

  • From: Tyler Littlefield <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 30 Jun 2010 17:17:17 -0600

Thanks for the help, btw. relaly appriciated. I'll get it eventually, I'm just 
going to have to hack at it for a few more hours, was hoping someone here could 
throw ideas at me, which you did, but it was harder because you didn't know how 
the system worked, some stuff to think about, though. :)
                Thanks,
Tyler Littlefield
        http://tds-solutions.net
        Twitter: sorressean

On Jun 30, 2010, at 5:14 PM, Tyler Littlefield wrote:

> No, it doesn't fwrite classes, just POD types.
>               Thanks,
> Tyler Littlefield
>       http://tds-solutions.net
>       Twitter: sorressean
> 
> On Jun 30, 2010, at 5:11 PM, qubit wrote:
> 
>> Ok, here's the situation --
>> class C : public A, public B {};
>> B has a virtual function -- in fact, it has virtuals. Therefore C has a 
>> virtual pointer in it.
>> C* cp = new C; // ok
>> If you say a* ap = cp;
>> all is fine.  But if you say
>> B* bp = cp;
>> this may not work in current compilers, I don't know -- but since B is 
>> positioned sizeof(A) bytes (supposedly) from the beginning of c, the 
>> compiler adds that many bytes to the value of cp and assigns the new value 
>> to bp.
>> You can probably imagine ways to mix things up.
>> 
>> Anyway, your strategy, from what you say, does not call fwrite on class 
>> types, correct? or does it?
>> And if it does, what do you want it to do?
>> Your strategy should work as long as fwrite is only called on types that are 
>> not pointers to classes.  If T is a class type, then you don't really know 
>> if the object T& t is a derived object or a plain T object.  If it is 
>> derived and you don't know it, you will be truncating data.
>> I hope this makes some kind of sense.
>> Sounds like your system is a great bit of engineering--hope you get it 
>> working right.
>> --le
>> 
>> 
>> 
>> ----- Original Message ----- 
>> From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
>> To: <programmingblind@xxxxxxxxxxxxx>
>> Sent: Wednesday, June 30, 2010 5:41 PM
>> Subject: Re: serialization, size errors... or something else.
>> 
>> 
>> How else should fwrite be used? I'm not sure what your getting at with the 
>> pointers, but I'm not passing pointers round besides the serialize object, 
>> which just writes the class members.__________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>> 
>> __________
>> View the list's information and change your settings at 
>> //www.freelists.org/list/programmingblind
>> 
> 
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: