Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 24 Aug 2012 09:53:16 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: compatability: bits/syscall.h requires C99

* Rich Felker <dalias@...ifal.cx> [2012-08-23 22:34:25 -0400]:
> OK, after discussion on IRC, the 2 options under consideration are:
> 
> #if __STDC_VERSION__ < 199901L && defined(__GNUC__)
> #define inline __inline
> #define restrict __restrict
> #elif __STDC_VERSION__ < 199901L
> #define inline
> #define restrict
> #endif
> 
> and
> 
> #if __STDC_VERSION__ >= 199901L
> #define __inline inline
> #define __restrict restrict
> #endif
> 
> added near the top of headers that need to use inline and/or restrict.

this won't work with c++, nor old strict c compilers
without __inline and __restrict and can break various
c parsing tools (ctags, swig, various lints, ..)

i'd use

#ifdef __cplusplus
#define __inline inline
#define __restrict
#elif __STDC_VERSION__ >= 199901L
#define __inline inline
#define __restrict restrict
#elif !defined(__GNUC__)
#define __inline
#define __restrict
#endif

so any standard c99 compiler will get the inline/restrict
(tcc, pcc, gcc -std=c99, clang -std=c99) and any gnu c
compiler will get __inline/__restrict (gcc, clang)
but other tools won't see anything

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.