This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: <sys/sysmacros.h> is broken

On Feb  8 06:33, Eric Blake wrote:
> STC showing that sysmacros doesn't work when included indirectly in C99
> mode:
> $ cat foo.c
> #include <sys/types.h>
> int main() { return makedev(0,0); }
> $ gcc -o foo foo.c
> $ gcc -o foo foo.c --std=c99
> /tmp/ccT40f0H.o:foo.c:(.text+0x1e): undefined reference to
> `_gnu_dev_makedev'
> collect2: ld returned 1 exit status

And why is that so?

Here's the definition of _ELIDABLE_INLINE in _ansi.h:

  /*  The traditional meaning of 'extern inline' for GCC is not
    to emit the function body unless the address is explicitly
    taken.  However this behaviour is changing to match the C99
    standard, which uses 'extern inline' to indicate that the
    function body *must* be emitted.  If we are using GCC, but do
    not have the new behaviour, we need to use extern inline; if
    we are using a new GCC with the C99-compatible behaviour, or
    a non-GCC compiler (which we will have to hope is C99, since
    there is no other way to achieve the effect of omitting the
    function if it isn't referenced) we just use plain 'inline',
    which c99 defines to mean more-or-less the same as the Gnu C
    'extern inline'.  */
  #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
  /* We're using GCC, but without the new C99-compatible behaviour.  */
  #define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
  /* We're using GCC in C99 mode, or an unknown compiler which 
    we just have to hope obeys the C99 semantics of inline.  */
  #define _ELIDABLE_INLINE __inline__

I really don't care for strict compiler modes, but shouldn't that
have taken care of the problem?  If not, PTC.

> Another STC showing that sysmacros is broken as a standalone header:
> $ cat bar.c
> #include <sys/sysmacros.h>
> int main() { return makedev(0,0); }
> $ gcc -o foo foo.c
> In file include from foo.c:1:0:
> /usr/include/sys/sysmacros.h:14:18: error: expected `=', `,', `;',
> `asm', or `__attribute__' before `int'

This one's easy.  We just have to include sys/types.h.  I apply a


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]