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

0.3 error: use of undeclared identifier 'LOCK_EX' #26

Closed
ilovezfs opened this issue Mar 7, 2018 · 2 comments
Closed

0.3 error: use of undeclared identifier 'LOCK_EX' #26

ilovezfs opened this issue Mar 7, 2018 · 2 comments

Comments

@ilovezfs
Copy link

ilovezfs commented Mar 7, 2018

Error Message

failed: brew install --verbose --build-bottle nq

Stacktrace

        /usr/bin/sandbox-exec -f /tmp/homebrew20180307-15058-2u85ae.sb nice /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/build.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nq.rb --build-bottle --verbose
==> Downloading https://github.com/chneukirchen/nq/archive/v0.3.tar.gz
Already downloaded: /Users/brew/Library/Caches/Homebrew/nq-0.3.tar.gz
==> Verifying nq-0.3.tar.gz checksum
tar xzf /Users/brew/Library/Caches/Homebrew/nq-0.3.tar.gz
==> make all PREFIX=/usr/local/Cellar/nq/0.3
clang -g -Wall -O2    nq.c   -o nq
clang -g -Wall -O2    fq.c   -o fq
nq.c:256:20: error: use of undeclared identifier 'LOCK_EX'
        if (flock(lockfd, LOCK_EX) < 0) {
                          ^
nq.c:290:18: error: use of undeclared identifier 'LOCK_EX'
                        if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                      ^
nq.c:290:28: error: use of undeclared identifier 'LOCK_NB'
                        if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                                ^
nq.c:294:15: error: use of undeclared identifier 'LOCK_EX'
                                flock(fd, LOCK_EX);   /* sit it out.  */
                                          ^
nq.c:319:19: error: use of undeclared identifier 'LOCK_EX'
                                if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                              ^
nq.c:319:29: error: use of undeclared identifier 'LOCK_NB'
                                if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                                        ^
nq.c:323:16: error: use of undeclared identifier 'LOCK_EX'
                                        flock(fd, LOCK_EX);   /* sit it out.  */
                                                  ^
7 errors generated.
make: *** [nq] Error 1
make: *** Waiting for unfinished jobs....

Homebrew/homebrew-core#24949

@ghost
Copy link

ghost commented Mar 7, 2018

Yes, a similar problem exists on FreeBSD here.

cc -g -Wall -O2    nq.c   -o nq
In file included from nq.c:32:
/usr/include/sys/file.h:223:2: error: unknown type name 'u_int'
        u_int   xf_flag;        /* flags (see fcntl.h) */
        ^
nq.c:256:6: warning: implicit declaration of function 'flock' is invalid in C99 [-Wimplicit-function-declaration]
        if (flock(lockfd, LOCK_EX) < 0) {
            ^
nq.c:256:20: error: use of undeclared identifier 'LOCK_EX'
        if (flock(lockfd, LOCK_EX) < 0) {
                          ^
nq.c:290:18: error: use of undeclared identifier 'LOCK_EX'
                        if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                      ^
nq.c:290:28: error: use of undeclared identifier 'LOCK_NB'
                        if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                                ^
nq.c:294:15: error: use of undeclared identifier 'LOCK_EX'
                                flock(fd, LOCK_EX);   /* sit it out.  */
                                          ^
nq.c:319:19: error: use of undeclared identifier 'LOCK_EX'
                                if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                              ^
nq.c:319:29: error: use of undeclared identifier 'LOCK_NB'
                                if (flock(fd, LOCK_EX | LOCK_NB) == -1 &&
                                                        ^
nq.c:323:16: error: use of undeclared identifier 'LOCK_EX'
                                        flock(fd, LOCK_EX);   /* sit it out.  */
                                                  ^
1 warning and 8 errors generated.
gmake: *** [<builtin>: nq] Error 1

This line in nq.c should be removed again because it appears flock() is being hidden when it's defined.

#define _XOPEN_SOURCE 700

Patch

@ilovezfs
Copy link
Author

ilovezfs commented Mar 7, 2018

Thanks!

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