deadpixi / sam

An updated version of the sam text editor.
Other
430 stars 46 forks source link

problem to compile; ‘F_TLOCK’ undeclared #128

Closed rudolfII closed 5 months ago

rudolfII commented 5 months ago

Hello, I have a problem to compile sam:

make make[1]: Entering directory '/home/ruda/soft/sam/libXg' gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o arith.o arith.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o balloc.o balloc.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o bitblt.o bitblt.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o border.o border.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o bscreenrect.o bscreenrect.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o clipr.o clipr.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o cursorset.o cursorset.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o cursorswitch.o cursorswitch.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o gcs.o gcs.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o getrect.o getrect.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o gwin.o gwin.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o ldconvert.o ldconvert.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o menuhit.o menuhit.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o rectclip.o rectclip.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o rune.o rune.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o string.o string.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o texture.o texture.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o wrbitmap.o wrbitmap.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -c -o xtbinit.o xtbinit.c ar rv libXg.a arith.o balloc.o bitblt.o border.o bscreenrect.o clipr.o cursorset.o cursorswitch.o gcs.o getrect.o gwin.o ldconvert.o menuhit.o rectclip.o rune.o string.o texture.o wrbitmap.o xtbinit.o ar: creating libXg.a a - arith.o a - balloc.o a - bitblt.o a - border.o a - bscreenrect.o a - clipr.o a - cursorset.o a - cursorswitch.o a - gcs.o a - getrect.o a - gwin.o a - ldconvert.o a - menuhit.o a - rectclip.o a - rune.o a - string.o a - texture.o a - wrbitmap.o a - xtbinit.o : libXg.a make[1]: Leaving directory '/home/ruda/soft/sam/libXg' cd libframe; make make[1]: Entering directory '/home/ruda/soft/sam/libframe' gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frbox.o frbox.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frdelete.o frdelete.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frdraw.o frdraw.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frinit.o frinit.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frinsert.o frinsert.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frptofchar.o frptofchar.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frselect.o frselect.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frstr.o frstr.c gcc -std=c99 -c -I../include -D_POSIX_C_SOURCE=200809L -I/usr/include/freetype2 -c -o frutil.o frutil.c ar rv libframe.a frbox.o frdelete.o frdraw.o frinit.o frinsert.o frptofchar.o frselect.o frstr.o frutil.o ar: creating libframe.a a - frbox.o a - frdelete.o a - frdraw.o a - frinit.o a - frinsert.o a - frptofchar.o a - frselect.o a - frstr.o a - frutil.o : libframe.a make[1]: Leaving directory '/home/ruda/soft/sam/libframe' cd sam; make make[1]: Entering directory '/home/ruda/soft/sam/sam' gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o sam.o sam.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o address.o address.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o buffer.o buffer.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o cmd.o cmd.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o error.o error.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o file.o file.c gcc -std=c99 -D_POSIX_C_SOURCE=200809L -I../include -I/usr/include/freetype2 -DRXPATH='"/usr/bin/ssh"' -c -o io.o io.c io.c: In function ‘canlocksocket’: io.c:297:9: warning: implicit declaration of function ‘lockf’ [-Wimplicit-function-declaration] 297 | if (lockf(fd, F_TLOCK, 0) != 0) | ^~~~~ io.c:297:19: error: ‘F_TLOCK’ undeclared (first use in this function) 297 | if (lockf(fd, F_TLOCK, 0) != 0) | ^~~ io.c:297:19: note: each undeclared identifier is reported only once for each function it appears in make[1]: [: io.o] Error 1 make[1]: Leaving directory '/home/ruda/soft/sam/sam' make: [Makefile:24: samdir] Error 2

If you can give me a hint as to what might be wrong... Thanks.

Ruda

sevan commented 5 months ago

Which OS / version are you compiling on?

rudolfII commented 5 months ago

I run Slackware 15.0 release and I am compiling the current head of the project:

; git pull remote: Enumerating objects: 34, done. remote: Counting objects: 100% (16/16), done. remote: Total 34 (delta 16), reused 16 (delta 16), pack-reused 18 Unpacking objects: 100% (34/34), 6.32 KiB | 134.00 KiB/s, done. From https://github.com/deadpixi/sam 46ec411..5d8acb3 master -> origin/master Updating 46ec411..5d8acb3 Fast-forward Makefile | 5 +++- doc/sam.1 | 6 ++---
sam/io.c | 2 +-
sam/regexp.c | 92 +++++++++++++++++++++++++++++++++++-----------------------------------
sam/sam.c | 2 +-
ssam/Makefile | 21 ++++++++++++++++
ssam/ssam.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 138 insertions(+), 52 deletions(-)
create mode 100644 ssam/Makefile
create mode 100755 ssam/ssam.sh
;

the version 46ec411 I was able to compile back then. But the error is not caused by the update, I think, since after

git checkout 46ec411

I get the same error.

Ruda

sevan commented 5 months ago

Hmm, if you grep /usr/include for F_TLOCK, is it defined anywhere & if so where? On Ubuntu I see it defined twice in unistd.h & fcntl.h, for Slackware?

rudolfII commented 5 months ago

; find /usr/include -type f -exec grep F_TLOCK {} /dev/null \; /usr/include/ruby-3.0.0/x86_64-linux/rb_mjit_min_header-3.0.6.h:#define F_TLOCK 2 /usr/include/fcntl.h:# define F_TLOCK 2 / Test and lock a region for exclusive use. / /usr/include/unistd.h:# define F_TLOCK 2 / Test and lock a region for exclusive use. /

sevan commented 5 months ago

F_TLOCK guarded off for me

#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
                                               && !defined __USE_POSIX))
/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both
   files consistent.  Some systems have them there and some here, and some
   software depends on the macros being defined without including both.  */

/* `lockf' is a simpler interface to the locking facilities of `fcntl'.
   LEN is always relative to the current file position.
   The CMD argument is one of the following.  */

# define F_ULOCK 0      /* Unlock a previously locked region.  */
# define F_LOCK  1      /* Lock a region for exclusive use.  */
# define F_TLOCK 2      /* Test and lock a region for exclusive use.  */
# define F_TEST  3      /* Test a region for other processes locks.  */

....

Add -D__USE_MISC to STANDARDS variable in config.mk.def and try rebuilding.

rudolfII commented 5 months ago

Ok, I will try, but isn't the main problem, that: io.c:297:9: warning: implicit declaration of function ‘lockf’ [-Wimplicit-function-declaration]?

ie, not only F_TLOCK is not known, but there is the prototype for the function completely missing?

rudolfII commented 5 months ago

... I added the -D__USE_MISC to config.mk.def STANDARDS variable, ran make clean, ran make, with the same result and error.

sevan commented 5 months ago

Ok, I will try, but isn't the main problem, that: io.c:297:9: warning: implicit declaration of function ‘lockf’ [-Wimplicit-function-declaration]?

ie, not only F_TLOCK is not known, but there is the prototype for the function completely missing?

You're right. There's 2 issues, yours is the root cause of F_TLOCK not being defined. Manual for lockf sheds more light.

sevan commented 5 months ago

Unhelpful but I was able to compile the latest code from the repo on Ubuntu 23.10 riscv64. clone repo & run make, without change.

rudolfII commented 5 months ago

Ok. I had an old config.mk from the past. And it caused that config.mk.def was not used during make. My old config.mk did not have D_XOPEN_SOURCE=500 there that the distributed config.mk.def now has. After I removed the config.mk, config.mk.def was used, and the program compiled. I note that the -D__USE_MISC is not necessary for me to compile.