Hello pps, I'd argue that serialization's basically the same as marshalling or using CArchive to serialize in a windows environment. When you serialize you're enforcing a standard for data packing and alignment so, you're simply solving the problem in a different way. You're throwing a layer over top of the whole problem that solves it for you.
If you're not serializing and want to save a struct to a blob then you run into both alignment and possibly structure packing problems (if the program reading the database was compiled with either a different compiler and/or has a different structure packing enforced). If you think about it, if structure packing isn't the same, you can't really use the "blob as struct" at all can you? C Friday, December 9, 2005, 6:04:35 AM, you wrote: p> Teg wrote: >> Hello Nathan, >> >> Depends on how you access them. Most RISC CPU's can't do unaligned access >> to multi-byte values like int's and long, they'll segfault. Intel >> CPU's don't have this problem. If you memcpy the values into place, >> this is a non-issue. You see it alot with embedded CPU's. >> >> Without knowing his environment, there's no way to guess how this >> would shake out. It'll work as long as the structs don't have pointers >> in them. That means anything other than naked structs won't work with >> the blob technique (no strings or C++ classes). You know, there's a >> whole process that I believe Microsoft calls marshalling which is used >> to take structs of all sorts and send them over a wire and >> re-constitute them on the other side. It's fairly complicated. >> >> My guess is he wants to store two ints and we're getting way too >> complicated but, that's just a guess. p> In fact, it's very simple to have multibyte values to be put into blobs p> (or, simply, some binary strings/buffers). IMHO, it's almost always a p> very bad decision to use memcpy for a couple of ints (alignment & p> padding problems for structs). Better, write some small functions that p> print/read data to/from binary strings. What is more interesting is to p> be able to store complex objects, where you have pointers to dynamically p> allocated objects etc., that's where things get hairy... p> I don't know about what's microsoft's marshalling is, but this all p> comes down to a task known as serialization and that's the real solution p> to all such problems where you want store arbitrary data in blobs or p> whatever. For c++ I use boost::serialization and I can put quite crazy p> (multiple inherited & polymorphic) big objects into sqlite without even p> knowing how to to put PODs into sqlite blobs -- Best regards, Teg mailto:[EMAIL PROTECTED]

