Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#61147 closed defect (fixed)

xournal @0.4.8.2016_1: error: implicit declaration of function 'read', 'write', 'close'

Reported by: mzucker (Matt Zucker) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.6.3
Keywords: catalina haspatch Cc:
Port: xournal

Description

Apparently the xournal source code makes liberal use of undeclared functions, which are errors with an up-to date macOS and Clang. The build halts on an error when it encounters undeclared functions in the source. Here's a relevant log snippet:

:info:build sft.c:742:33: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
:info:build         if (listFind(glyphlist, (void *) (int) index)) {
:info:build                                 ^
:info:build sft.c:756:31: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
:info:build         listAppend(glyphlist, (void *) (int) index);
:info:build                               ^
:info:build ttcr.c:420:9: error: implicit declaration of function 'write' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build     if (write(fd, ptr, length) != length) {
:info:build         ^
:info:build ttcr.c:420:9: note: did you mean 'fwrite'?
:info:build /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h:165:9: note: 'fwrite' declared here
:info:build sft.c:940:35: warning: cast to 'void *' from smaller integer type 'guint32' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
:info:build size_t   fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite);
:info:build             listAppend(glyphlist, (void *) glyphID);
:info:build                                   ^
:info:build          ^
:info:build ttcr.c:426:5: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build     close(fd);
:info:build     ^
:info:build sft.c:1633:13: error: implicit declaration of function 'read' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build         if (read(fd, buffer, 12) == 12) {
:info:build             ^
:info:build sft.c:1633:13: note: did you mean 'fread'?
:info:build /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h:158:9: note: 'fread' declared here
:info:build size_t   fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream);
:info:build          ^
:info:build sft.c:1637:9: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build         close(fd);
:info:build         ^
:info:build sft.c:1806:19: error: implicit declaration of function 'close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build     if (fd != -1) close(fd);
:info:build                   ^
:info:build sft.c:1847:27: warning: cast to 'void *' from smaller integer type 'guint32' (aka 'unsigned int') [-Wint-to-void-pointer-cast]
:info:build     listAppend(glyphlist, (void *) glyphID);

Adding the line

configure.cflags-append "-std=gnu89 -Wno-implicit-function-declaration"

to the Portfile allows xournal to build successfully.

I will attach a patched Portfile if I can figure out how...

Attachments (1)

Portfile-xournal.diff (336 bytes) - added by mzucker (Matt Zucker) 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by mzucker (Matt Zucker)

Attachment: Portfile-xournal.diff added

comment:1 Changed 4 years ago by mf2k (Frank Schima)

Cc: ryandesign@… removed
Keywords: catalina, haspatchcatalina haspatch
Owner: set to ryandesign
Status: newassigned

comment:2 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Status: assignedaccepted
Summary: xournal @0.4.8.2016_1: build failure with recent clang on Catalinaxournal @0.4.8.2016_1: error: implicit declaration of function 'read', 'write', 'close'

Thanks for letting me know about the problem.

Instead of disabling the compiler check, I will fix the problem by including the correct headers, and I'll report the problem and the patch to the developers.

I'm not sure why you added -std=gnu89; we've been compiling the port with clang since Lion (2011) which defaults to C99 which has been fine for this port, as far as I know.

comment:3 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: acceptedclosed

In b8e0193980a56989a137a2db225ff19aaf6d5ebf/macports-ports (master):

xournal: Fix implicit declaration of functions

Closes: #61147

comment:4 Changed 4 years ago by mzucker (Matt Zucker)

I added the -std=gnu89 because the errors I saw said implicit declarations are invalid in C99. But glad for any fix, thanks!

Note: See TracTickets for help on using tickets.