#39 Compile failure due to _XOPEN_SOURCE

closed-fixed
None
5
2008-08-03
2008-06-20
No

In kiklib/src/kik_pty_streams.c _XOPEN_SOURCE is explicitly defined unless __APPLE__ is defined. This is a bad idea and doesn't match the explanatory comment. There are many Unix systems beside Mac OS X which do not use GNU libc (Solaris, NetBSD, OpenBSD, FreeBSD, HP-UX, OSF etc.) and it verifiably breaks compiling on NetBSD. Checking for GNU libc can be achieved by testing for __GLIBC__ and __GLIBC_MINOR__. It is much safer to set _GNU_SOURCE on such systems instead which will basically pull in everything available. It would be a better idea to put these 3 lines in a commonly included header file.

A patch is attached.

Discussion

  • MINAMI Hirokazu

    MINAMI Hirokazu - 2008-08-02
    • assigned_to: nobody --> h_minami
    • status: open --> pending
     
  • MINAMI Hirokazu

    MINAMI Hirokazu - 2008-08-02

    Logged In: YES
    user_id=203671
    Originator: NO

    In my understanding,
    - __GLIBC__ and __GLIBC_MINOR__ are defined only *after* #include <features.h>
    and
    - _GNU_SOURCE should be defined *before* include the header file

    So defining _GNU_SOURCE based on __GLIBC__ and __GLIBC_MINOR__ do not make sense to me.
    Dit it worked for you?

     
  • Christian Biere

    Christian Biere - 2008-08-02

    Logged In: YES
    user_id=643728
    Originator: YES

    You don't need to explicitely <features.h>, any other standard C header file should do. You can check this before compiling with autoconf, for example

     
  • Christian Biere

    Christian Biere - 2008-08-02
    • status: pending --> open
     
  • MINAMI Hirokazu

    MINAMI Hirokazu - 2008-08-02

    Logged In: YES
    user_id=203671
    Originator: NO

    I've added detection of __GLIBC__ in configure.
    now kik_pty_streams.c should:
    - on non-glibc environment, no longer define _XOPEN_SOURCE
    - on glibc, define only _GNU_SOURCE (instead of XOPEN_SOURCE + _BSD_SOURCE)
    (see CVS head)

    Since I've just tested it with linux-amd64 + glibc2.7,
    please confirm whether it works on the platform you care.

     
  • Christian Biere

    Christian Biere - 2008-08-03

    Logged In: YES
    user_id=643728
    Originator: YES

    It compiles on NetBSD now. Thanks.

     
  • MINAMI Hirokazu

    MINAMI Hirokazu - 2008-08-03
    • status: open --> closed-fixed
     
  • MINAMI Hirokazu

    MINAMI Hirokazu - 2008-08-03

    Logged In: YES
    user_id=203671
    Originator: NO

    Thanks for testing, now closing this bug...

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks