Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O_CLOEXEC not always available... #1

Closed
antijn opened this issue Apr 29, 2013 · 0 comments
Closed

O_CLOEXEC not always available... #1

antijn opened this issue Apr 29, 2013 · 0 comments

Comments

@antijn
Copy link

antijn commented Apr 29, 2013

O_CLOEXEC is relatively new (for some definition of new), it was included in POSIX 2008. It was available earlier on Linux, but only if _GNU_SOURCE was defined.

This leads to libugpio failing to compile for some environments, my Debian Squeeze box for example:
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT gpio.lo -MD -MP -MF .deps/gpio.Tpo -c -o gpio.lo gpio.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT gpio.lo -MD -MP -MF .deps/gpio.Tpo -c gpio.c -fPIC -DPIC -o .libs/gpio.o
gpio.c: In function ‘gpio_check’:
gpio.c:71: error: ‘O_CLOEXEC’ undeclared (first use in this function)
gpio.c:71: error: (Each undeclared identifier is reported only once
gpio.c:71: error: for each function it appears in.)
make[2]: *** [gpio.lo] Error 1

I can see three possible solutions:

  1. Add a simple

    define _GNU_SOURCE

    before including fcntl.h
    This will only work on Linux (but hey, I don't think any other OS uses sysfs gpio... :-)

  2. Add a:

    ifndef O_CLOEXEC

    define O_CLOEXEC 0

    endif

Will eliminate the compile error, but may disable O_CLOEXEC where it actually could work.

  1. Do some autoconf magic (which I am not a master of)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant