Re: Linux Kernel include files

H. Peter Anvin
2007-06-28T04:17:17Z

Kyle Moffett wrote:
>
> Gah, this particular topic and a few other similar header-compatibility
> ones show up once a month on LKML; I should probably just make a patch
> to fix all the types.h files and be done with it. The proper solution
> is this:
>
> # if __STDC_VERSION__ >= 19901L
> typedef signed long long __s64;
> typedef unsigned long long __u64;
> # elif defined(__GNUC__)
> __extension__ typedef signed long long __s64;
> __extension__ typedef unsigned long long __u64;
> # else
> # error "Your compiler doesn't support long long (IOW: It sucks).
> Please get a new one"
> # endif
>
> That way if you have any kind of vaguely-long-long-compatible compiler
> then it will work, and otherwise you'll get a nice useful error
> message. It also makes sure that GCC doesn't spew warnings/errors when
> in c89-pedantic mode. The "__extension__" keyword is designed for use
> in implementation header files which want to use GCC-isms unconditionally.
>

__extension__ should be macroized if so.

However, since something that doesn't have "long long" won't be able to
compile those headers, there is absolutely no reason to not simply use
it -- you get an error message on that line, which is good enough.
There is definitely no reason to use a test like the one above, which is
wrong for several supportable compilers.

-hpa