[sane-devel] sanei_scsi.c compile error (Sg_scsi_id)

abel deuring a.deuring@satzbau-gmbh.de
Thu, 07 Mar 2002 21:31:15 +0100


David Paschal wrote:
> 
> Hi,
> 
> When compiling the latest CVS sane-backends on RedHat 6.2 (upgraded to kernel
> 2.2.18), I get the following error:
> 
> gcc -c -DHAVE_CONFIG_H -I. -I. -I../include -I../include -D_GNU_SOURCE -DPATH_SANE_CONFIG_DIR=/usr/local/etc/sane.d -DPATH_SANE_DATA_DIR=/usr/local/share -DV_MAJOR=1 -DV_MINOR=0 -g -O2 -W -Wall -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -pedantic -ansi sanei_scsi.c  -fPIC -DPIC -o .libs/sanei_scsi.lo
> sanei_scsi.c: In function `sanei_scsi_open_extended':
> sanei_scsi.c:1159: `Sg_scsi_id' undeclared (first use in this function)
> sanei_scsi.c:1159: (Each undeclared identifier is reported only once
> sanei_scsi.c:1159: for each function it appears in.)
> sanei_scsi.c:1159: parse error before `devinfo'
> sanei_scsi.c:1182: `devinfo' undeclared (first use in this function)
> sanei_scsi.c: In function `sanei_scsi_req_enter2':
> sanei_scsi.c:1908: warning: cast discards `const' from pointer target type
> sanei_scsi.c: In function `sanei_scsi_find_devices':
> sanei_scsi.c:2521: warning: assignment discards `const' from pointer target typesanei_scsi.c: In function `sanei_scsi_req_enter':
> sanei_scsi.c:4337: warning: cast discards `const' from pointer target type
> sanei_scsi.c:4345: warning: cast discards `const' from pointer target type
> sanei_scsi.c: In function `sanei_scsi_cmd':
> sanei_scsi.c:4353: warning: cast discards `const' from pointer target type
> sanei_scsi.c:4361: warning: cast discards `const' from pointer target type
> 
> A relevant portion of the ./configure output:
> 
> checking for scsi.h... no
> checking for sys/scsi.h... no
> checking for sys/scsicmd.h... no
> checking for sys/scsiio.h... no
> checking for bsd/dev/scsireg.h... no
> checking for scsi/sg.h... yes
> checking for /usr/src/linux/include/scsi/sg.h... yes
> ...
> checking for sys/scsi/scsi.h... no
> checking for sys/scsi/sgdefs.h... no
> checking for sys/scsi/targets/scgio.h... no
> checking for apollo/scsi.h... no
> 
> The problem seems to be that /usr/src/linux/include/scsi/sg.h has the
> necessary typedef for Sg_scsi_id, but scsi/sg.h, which takes precedence
> when both files are available, doesn't.  If I hack config.h and comment
> out the line "#define HAVE_SCSI_SG_H 1", then it compiles successfully.
> 
> Hopefully there's somebody better qualified than I am to determine an
> appropriate fix or workaround that doesn't break anything else, so the
> next stable release won't have this problem.  :-)

David,

the most easy fix is probably to change line 1159 from

	Sg_scsi_id devinfo;

to

	SG_scsi_id devinfo;

(SG_scsi_id is defined in sanei_scsi.c , line 289, while Sg_scsi_id is
defined in sg.h .)

The intersting detail is that the error occured quite late; it seems
that the differences between the sg.h from the kernel and from libc
begin to disappear ;)

Abel