[ale] Battling Distros and unwrapped '#include's

Pete Hardie pete.hardie at gmail.com
Wed Apr 30 14:13:27 EDT 2008


On Wed, Apr 30, 2008 at 1:23 PM, John Mills <johnmills at speakeasy.net> wrote:
> ALErs -
>
> Different engineers in our development group use different Linux distros
> and we seem to have a cross-file of system *.h files defining basic types.
>
> In particular, one of our own product's files attempts to conditionally
> define basic integer types as follows:
>
> ************<common.h>********************
> /* Types */
>
> #ifndef __u8
> #define __u8 unsigned char
> #endif
> #ifndef __u16
> #define __u16 unsigned short
> #endif
> #ifndef __u32
> #define __u32 unsigned long
> #endif
> #ifndef __s8
> #define __s8 signed char
> #endif
> #ifndef __s16
> #define __s16 signed short
> #endif
> #ifndef __s32
> #define __s32 signed long
> #endif
>
> *****************************************
>
> Three distros react in different ways to this fragment:
>
> 1. openSuSE-10.x can't build if these definitions are _not_ included, but
> crashes on duplicated definitions from <asm/types.h> if I instead include
> <linux/types.h>. Specifically with a flurry of:
>
>  "/usr/include/asm/types.h:13: error: duplicate -1signed"
>
> 2. FC8 can't build if these definitions _are_ included, on account of
> duplicate declarations.
>
> 3. Ubuntu-8.04 doesn't care - it apparently wraps these types properly.
>
> First, the "#ifndef/#endif" contructions clearly don't work properly with
> 'typedef' defined types, and
> Second, there seem to be problems with the system '#include's wrappers, at
> least in openSuSE.
>
> Any suggestions how to code around this in a fairly portable fashion? We
> have conditional compilation for other targets, but for our purposes it
> would be good to have a single target for our Linux/x86 builds.

Put the various distros' versions in separate files, and have the main
one do something liek this:

#ifdef SUSE
#include SUSE_INTEGER_DEFS.h
#endif
#ifdef FEDORA
#include FEDORA_INTEGER_DEF.h
#endif
......


-- 
Pete Hardie
--------
Better Living Through Bitmaps


More information about the Ale mailing list