Martin Ling wrote:
> > You can't map raw data from the file to a struct like this for at least
> > 2 reasons:
> >  - the compiler is free to add some alignment padding between the struct
> >  fields which would prevent them to map to the data you expect
> >  - the data stored in the file may not match the endianness of the host
> >  trying to read it
> > 
> > To solve this issue, you should use the RL16() and RL32() macro to read
> > directly from raw data. (you may need to add a RL64() version of the
> > macro)
> 
> Note you can use __attribute((packed))__ on the struct in GCC (and
> similar constructs in other compilers), to avoid the first problem.

Don't build that kind of compiler-dependence into software intended
for widespread use.

Write packing and unpacking functions instead, using those macros.


//Peter

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to