[sane-devel] Replacing u_char and friends (was Re: [PATCH] Port to OS X)

Olaf Meeuwissen paddy-hack at member.fsf.org
Tue Oct 20 12:52:18 UTC 2015

Hi Luiz, Devs,

Luiz Angelo Daros de Luca writes:

> Olaf and Yurii,
> The sys/type.h problem is the same I face while compiling with musl
> instead of glibc.  There are just some files that miss it. I have a
> patch for them but it still misses the ifdef around it.  Check the
> other patches that might easy your port.
> https://github.com/openwrt/packages/blob/master/utils/sane-backends/patches/

I looked at the 030-musl.patch and except maybe for the backend/hp*.c
files, all fixes seem to involve u_char and friends.  Now, ./configure
checks for their presence.  If they are absent, they will be defined
automatically for you in include/sane/config.h.  If they are present,
these defines are not provided and whoever uses them will need to add an
#include for a header that does, normally sys/types.h.  However, that
header may be absent itself, so ... 

Somehow, I get the impression that ./configure is only doing half of
this job.  On the other hand, (blindly?) including sys/types.h in the
config.h file seems pretty heavy handed too.  Moreover, that file may
not be there.

Now, if the issue is just u_char and friends, can't we just simply avoid
the whole issue and replace them with "unsigned char" and the like?  For
all I know that ought to work everywhere.
A similar suggestion was made (way back) on StackOverflow[1].

 [1] http://stackoverflow.com/questions/1918934/is-u-char-a-standard

Grepping for the ones that ./configure checks for (SANE_CHECK_U_TYPES in
acinclude.m4) with:

  $ git grep -wE 'u_(char|short|int|long)' master | wc -l

that would be quite a monster patch though.  Would such a patch be

# There are false positives in the above, e.g. the ones in acinclude.m4
# and in include/sane/config.h and its template.

I realize that this is not Yurii's sigset_t problem but thought I would
mention it anyway.

Hope this helps,
Olaf Meeuwissen, LPIC-2            FSF Associate Member since 2004-01-27
Support Free Software               Support the Free Software Foundation
https://my.fsf.org/donate                        https://my.fsf.org/join
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9

More information about the sane-devel mailing list