[sane-devel] dc240 only works with GCC

Peter Fales psfales at lucent.com
Sat Oct 12 02:31:51 BST 2002


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.

--
Peter Fales


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
> 
> First of all, '#error' need a parameter to be ANSI C.  But the real
> problem is that '__attribute__((packed))' only work on GCC.  I suggest
> that this backend only is compiled when using GCC.  The real fix would
> be to rewrite this to be portable code.  I do not believe it is
> possible to get packed structs any portable way.
> 
> Here is a patch to fix the typo and use the available PACKED macro.
> 
> Index: dc240.h
> ===================================================================
> RCS file: /cvsroot/external/sane/sane-backends/backend/dc240.h,v
> retrieving revision 1.2
> diff -u -3 -p -u -w -r1.2 dc240.h
> --- dc240.h     2002/09/22 13:49:47     1.2
> +++ dc240.h     1994/10/11 16:48:31
> @@ -212,14 +212,14 @@ struct cam_dirent
>   * in the following dir_buf structure - it has to match data read from
>   * the camera.  gcc does this with __attribute__ ((packed))
>   */
> -#error
> +#  error "Please port to this compiler."
>  #endif
> 
>  struct dir_buf
>  {
>    SANE_Byte entries_msb PACKED;
>    SANE_Byte entries_lsb PACKED;
> -  struct cam_dirent entry[1000] __attribute__ ((packed));
> +  struct cam_dirent entry[1000] PACKED;
>  };
> 
>  struct cam_dirlist
> _______________________________________________
> Sane-devel mailing list
> Sane-devel at www.mostang.com
> http://www.mostang.com/mailman/listinfo/sane-devel



More information about the sane-devel mailing list