fanglingsu / vimb

Vimb - the vim like browser is a webkit based web browser that behaves like the vimperator plugin for the firefox and usage paradigms from the great editor vim. The goal of vimb is to build a completely keyboard-driven, efficient and pleasurable browsing-experience.
https://fanglingsu.github.io/vimb/
GNU General Public License v3.0
1.34k stars 100 forks source link

fcntl #664

Open BebeSparkelSparkel opened 3 years ago

BebeSparkelSparkel commented 3 years ago

Trying to build this on openBSD and having problems with undeclared identifier 'LOCK_EX' and 'LOCK_UN'.

Similar to #76 and #302. The fix/FreeBSD-compile-error branch seems to have been deleted.

I tried adding #include <fcntl.h> to file-storage.c. man flock.

$ gmake                           
create version.h
gmake[1]: Entering directory '/home/user/repos/vimb/src'
cc file-storage.o
file-storage.c:99:9: warning: implicit declaration of function 'flock' is invalid in C99 [-Wimplicit-function-declaration]
        flock(fileno(f), LOCK_EX);
        ^
file-storage.c:99:26: error: use of undeclared identifier 'LOCK_EX'
        flock(fileno(f), LOCK_EX);
                         ^
file-storage.c:103:26: error: use of undeclared identifier 'LOCK_UN'
        flock(fileno(f), LOCK_UN);
                         ^
1 warning and 2 errors generated.
fanglingsu commented 3 years ago

Is there someone using openBSD to help out to get file locking working? Or someone who could help to provide a patch dedicated for openBSD? @BebeSparkelSparkel as a first untestet shot you could add the #include <fcntl.h> after the include of sys/file.h in https://github.com/fanglingsu/vimb/blob/652f4111b6e11d0ce280ae2a7b5d8f09f85bb253/src/file-storage.c#L22. Accroding to https://man.openbsd.org/flock.2 this could be enough to compile vimb.

seanm commented 2 years ago

I don't know this project, but I found this ticket investigating some similar, where flock is not visible. Are you defining _POSIX_C_SOURCE?

The following output from an OpenBSD 6.9 machine may help you:

builder3$ cat test.c
#include <fcntl.h>

int main (void)
{
  flock(0,0);
  return 0;
}

builder3$ cc -fsyntax-only test.c 
builder3$ cc -fsyntax-only -D_BSD_SOURCE test.c
builder3$ cc -fsyntax-only -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L test.c
builder3$ cc -fsyntax-only -D_POSIX_C_SOURCE=200809L test.c               
test.c:5:3: warning: implicit declaration of function 'flock' is invalid in C99 [-Wimplicit-function-declaration]
  flock(0,0);
  ^
1 warning generated.

i.e. if you define _POSIX_C_SOURCE you seem to also need to define _BSD_SOURCE.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity within the last 60 days.