Menu

#248 lirc fails to compile if _XOPEN_SOURCE is not defined

0.9.5
closed
nobody
None
fixed
2016-12-20
2016-12-20
No

The following defines could/should be added to lib/curl_poll.c:

#ifndef _XOPEN_SOURCE
#define POLLRDNORM 0
#define POLLWRNORM 0
#define POLLRDBAND 0
#endif

Discussion

  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    .. or better

    #ifndef _XOPEN_SOURCE
    #define POLLRDNORM POLLIN
    #define POLLWRNORM POLLOUT
    #define POLLRDBAND POLLPRI
    #endif
    
     
  • Alec Leamas

    Alec Leamas - 2016-12-20

    Or this patch:

    diff --git a/lib/curl_poll.c b/lib/curl_poll.c
    index e6d7ebe..03caaeb 100644
    --- a/lib/curl_poll.c
    +++ b/lib/curl_poll.c
    @@ -37,6 +37,7 @@
     #include <sys/time.h>
     #include <sys/types.h>
    
    +#define _XOPEN_SOURCE
     #include "lirc/curl_poll.h"
    
     /* Convenience local macros */
    

    right? Which works even if these constants are defined elsewhere..

    Still curious why you run into this. Current lirc is really built on quite a lot of platforms, so you have some kind of specific setup. That said, this is a bug which should be fixed.

    Does the patch fix your problem?

     
  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    I cross-compile using a buildroot-2013.02 environment with uClibc. Yes, it's old, but i can't use a newer one in this particular case.
    Looking at the headers, what works is

    #define __USE_XOPEN
    

    instead of

    #define _XOPEN_SOURCE
    
     
  • Alec Leamas

    Alec Leamas - 2016-12-20

    Odd. What does 'man poll' say on your host? My manpage does not mention __USE_XOPEN, just _XOPEN_SOURCE..

    I assume you have actually tried"using _XOPEN_SOURCE?

     

    Last edit: Alec Leamas 2016-12-20
  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    Ok, now i have it. You have to define _XOPEN_SOURCE at the very beginning before all other includes (the macros are defined via an include in lirc_log.h).

    --- a/lib/curl_poll.c   
    +++ b/lib/curl_poll.c   
    @@ -20,6 +20,7 @@
     *
     ***************************************************************************/
    
    +#define _XOPEN_SOURCE
     #include "config.h"
     #include "lirc_log.h"
    
     
  • Alec Leamas

    Alec Leamas - 2016-12-20

    OK, this seems to be about /usr/include/features.h. Substituting the _XOPEN_SOURCE line with

    #define _XOPEN_SOURCE 700
    

    should fix it, right?

     
  • Alec Leamas

    Alec Leamas - 2016-12-20

    Which leads to the fact that lirc_log is included to early, I spotted that when looking into this. Maybe we should try a mor eproper fix. Does this patch make it?
    http://paste.fedoraproject.org/510015/14822324

     
  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    No, doesnt work. It's basically the same issue, the define must be before including lirc_log.h (actually before syslog.h).

     
    • Alec Leamas

      Alec Leamas - 2016-12-20

      Of, course, my bad. Sorry. This woirks then http://paste.fedoraproject.org/510051/3919114

       
      • Alec Leamas

        Alec Leamas - 2016-12-20

        Thiis is not my day... that link looks bad. Here, the same patch which I assume is OK?

        diff --git a/lib/curl_poll.c b/lib/curl_poll.c
        index e6d7ebe..ee53e2d 100644
        --- a/lib/curl_poll.c
        +++ b/lib/curl_poll.c
        @@ -19,9 +19,7 @@
         * KIND, either express or implied.
         *
         ***************************************************************************/
        -
         #include "config.h"
        -#include "lirc_log.h"
        
         #ifdef HAVE_SYS_SELECT_H
         #include <sys/select.h>
        @@ -37,7 +35,10 @@
         #include <sys/time.h>
         #include <sys/types.h>
        
        -#include "lirc/curl_poll.h"
        +#define _XOPEN_SOURCE 700
        +#include "lirc_log.h"
        +#include "curl_poll.h"
        +
        
         /* Convenience local macros */
        
         
  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    I cant access this, "The contents of this paste have been hidden"

     
    • Alec Leamas

      Alec Leamas - 2016-12-20

      On 20/12/16 14:10, felix schmidt wrote:

      I cant access this, "The contents of this paste have been hidden"

      ALready answered in bug...

      --a

       
  • Felix Schmidt

    Felix Schmidt - 2016-12-20

    Sorry .. now it's errno.h (or something included from there) that triggers the error ..
    Why not just put it to the top?

     
    • Alec Leamas

      Alec Leamas - 2016-12-20

      lirc is built on a multitude of platforms. I want to make the impact of this as small as possible. The real truth about how this package builds are the Debian and Fedora build servers, not the fact that it builds for you and me...

      Are you saying that including errno.h fails when _XOPEN_SOURCE is defined on your host? Could you please post the error message?

       
      • Felix Schmidt

        Felix Schmidt - 2016-12-20
        (...)
        Making all in lib
        make[3]: Entering directory '/export/tmp/fritz/ffritz/packages/x86/lirc/build/lib'
        make  all-am
        make[4]: Entering directory '/export/tmp/fritz/ffritz/packages/x86/lirc/build/lib'
        /bin/sh ../libtool --tag=CC   --mode=compile i686-buildroot-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I..  -I.. -Wall -Wp,-D_FORTIFY_SOURCE=2    -g -O2  -MT curl_poll.lo -MD -MP -MF .deps/curl_poll.Tpo -c -o curl_poll.lo curl_poll.c
        libtool: compile:  i686-buildroot-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I.. -I.. -Wall -Wp,-D_FORTIFY_SOURCE=2 -g -O2 -MT curl_poll.lo -MD -MP -MF .deps/curl_poll.Tpo -c curl_poll.c  -fPIC -DPIC -o .libs/curl_poll.o
        curl_poll.c: In function 'curl_poll':
        curl_poll.c:148:11: error: 'POLLRDNORM' undeclared (first use in this function)
        curl_poll.c:148:11: note: each undeclared identifier is reported only once for each function it appears in
        curl_poll.c:148:24: error: 'POLLWRNORM' undeclared (first use in this function)
        curl_poll.c:148:37: error: 'POLLRDBAND' undeclared (first use in this function)
        curl_poll.c: At top level:
        curl_poll.c:75:23: warning: 'curlx_tvnow' defined but not used [-Wunused-function]
        Makefile:500: recipe for target 'curl_poll.lo' failed
        

        If i put it this way it compiles fine:

        (...)
        #if !defined(HAVE_SELECT) && !defined(HAVE_POLL_FINE)
        #error "We can't compile without select() or poll() support."
        #endif
        
        #define _XOPEN_SOURCE 700
        #include <errno.h>
        #include <stdbool.h>
        #include <stdlib.h>
        #include <sys/time.h>
        #include <sys/types.h>
        
        #include "lirc_log.h"
        #include "curl_poll.h"
        (...)
        

        Moving the define anywhere below the include of errno.h fails with the above error.

         
        • Alec Leamas

          Alec Leamas - 2016-12-20

          OK, I think I have it. It's about feature_test_macros(7). According to this, the _XOPEN_SOURCE definition should precede all header inclusions, i. e., be at the very top.

          So, this should work: http://paste.fedoraproject.org/510097/82247508 Or?

          EDIT: fix link.

           

          Last edit: Alec Leamas 2016-12-20
          • Felix Schmidt

            Felix Schmidt - 2016-12-20

            Yep, thanks!

             
  • Alec Leamas

    Alec Leamas - 2016-12-20
    • status: open --> closed
    • Resolution: na --> fixed
    • Milestone: Future --> 0.9.5
     
  • Alec Leamas

    Alec Leamas - 2016-12-20

    Fixed in [420505] (master) and [daa09c] (release-0_9_4). Thanks for reporting and testing!

     

    Related

    Commit: [420505]
    Commit: [daa09c]


Log in to post a comment.