One for the experts... [message #13384] |
Thu, 05 November 1998 00:00 |
gadagkar
Messages: 3 Registered: November 1998
|
Junior Member |
|
|
I have been using IDL (on a Linux OS) for R&D work but our normal application
software is a DOS application written in C. The database and image header
structures have been written such that there are no bytes appended to fields
of structures that do not align themselves on 8 byte boundaries. The spaces
(if any) between fields of a structure are removed by using the "packed"
attribute (GNU CC). So what I have to do is read binary files that have
headers that are "packed" from an IDL application running on a Linux box.
Has anyone ever run into such a situation?
My solution has been the following.
I have a callable (i.e., using CALL_EXTERNAL) C function that opens the
database or image files and reads the headers and data. I use two include
files each containing the same header structures (with different names) but
one has the structres packed and the other has structures that do not use
the "packed" attribute. I use the "packed" structures to read from the binary
files and then copy field at a time to the normal (or unpacked) structures.
Then the unpacked type is returned to IDL when this C function is called
from IDL.
This technique works fine, but makes me waste some memory. The packing
technique is good since it makes our data files platform independent (except
when there is byte swapping).
IDL structures use the default byte alignment for the given Hardware/OS. So
if one tries to read binary files containing structures written from one OS
(say DOS, Windows, etc.) from a UNIX m/c then we have to worry about byte
alignments. I would be interested in getting some ideas on how to get around
this problem.
Rishi.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
|
|
|