I am trying to build a package (libnet) in Solaris and I found that in Solaris there are no u_xxx_t
but uxxx_t
defined in sys/types.h
I had 2 questions:
1-Shouldn't autotools take care of this for me?
2-I guess I'm not the first one facing this (although google was little help) is there a standard/eficient/correct/quick way of overcoming this?
The most reasonable way of overcoming tis is to stick with the standard spelling of the type names (even if that standard is a "future" one for the implementation you are using). C99 introduced a standard nomenclature for such type names and in C99 it is uint8_t
. So, even if you are using a C89/90 compiler I'd suggest you use uint8_t
in your code. If on some platform it is unavailable or spelled differently, you simply introduce a platform-specific typedef name that "converts" the spelling
typedef u_int8_t uint8_t;
For this to work you'll need a header file that is included into every translation unit. Normally, each project has one created specifically for solving issues like this one.
The typename uint8_t
is standard, so I'm not sure where you found u_int8_t
.
This is simple enough that you can do it a fast, dumb way with perl
(or sed, if you must), and fix any minor problems that it causes by hand:
perl -pi.orig -e "s/\bu_(\w+_t)\b/u$1/g" *.c
(This will save the original, unmodified files with the .orig
suffix.)
#define u_xxx_t uxxx_t
or
typedef wrapped in a #ifdef block, i.e. typedef u_xxx_t uxxx_t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With