[sane-devel] Re: dc240 only works with GCC
abel deuring
adeuring at gmx.net
Sat Oct 12 11:04:39 BST 2002
Peter Fales wrote:
> I've made this change. I don't see any easy way to fix it
> in portable way, and more importantly I don't have any way to
> test it. I'll be glad to take patches if someone wants to supply
> them.
>
>
> On Fri, Oct 11, 2002 at 06:50:14PM +0200, Petter Reinholdtsen wrote:
>
>>
>> I just discovered this code when trying to find out why the CVS
>> version of sane-backends fail to compile on HP/UX using the native
>> compiler.
>>
>> #ifdef __GNUC__
>> #define UNUSEDARG __attribute__ ((unused))
>> #define PACKED __attribute__ ((packed))
>> #else
>> #define UNUSEDARG
>> /* You need to figure out a way to ensure that there are no holes
>> * in the following dir_buf structure - it has to match data read from
>> * the camera. gcc does this with __attribute__ ((packed))
>> */
>> #error
>> #endif
>>
>>
Well, perhaps I don't get the point -- but looking through dc240.h, it
seems to me that all you want to achieve is that struct dir_buf does not
have any padding bytes between members of the struct.
All the SCSI backends have to deal with the same problem for SCSI
command and data buffers: you may have non-32-bit-aligned 32 bit
integers, and the integers are perhaps not in the "native" byte order of
the machine.
Regading struct dir_buf, what about the following (written without a
serious look into dc240.c -- please bear with me, if I'm writing
nonsense...):
#define CAMDIRENTRYSIZE 20
#define DIRENTRIES 1000
SANE_Byte dir_buf[2 + CAMDIRENTRYSIZE * DIRENTRIES];
#define get_name(entry) (SANE_Char*) &dir_buf[4+CAMDIRENTRYSIZE*(entry)]
#define get_attr(entry) dir_buf[4+11+CAMDIRENTRYSIZE*(entry)]
#define get_create_time(entry) \
( dir_buf[4+12+CAMDIRENTRYSIZE*(entry)] << 8 \
+ dir_buf[4+13+CAMDIRENTRYSIZE*(entry)])
Abel
More information about the sane-devel
mailing list