Opened 4 years ago

Closed 4 years ago

#61790 closed defect (fixed)

freeimage: fails to compile on macOS 11.0 due to C99 implicit declaration issues

Reported by: mdave (David Moxey) Owned by: mdave (David Moxey)
Priority: Normal Milestone:
Component: ports Version:
Keywords: bigsur catalina haspatch Cc: AlAnMikhayloff
Port: freeimage

Description

This seems to be a pretty common theme amongst a lot of ports, so will aim to help out where I can to fix things. A few C99 errors on macOS 11.0 for the freeimage source, e.g.

/usr/bin/clang -Os -arch x86_64 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -O3 -fPIC -fexceptions -fvisibility=hidden -DOPJ_STATIC -DNO_LCMS -DDISABLE_PERF_MEASUREMENT -D__ANSI__ -I. -ISource -ISource/Metadata -ISource/FreeImageToolkit -ISource/LibJPEG -ISource/LibPNG -ISource/LibTIFF4 -ISource/ZLib -ISource/LibOpenJPEG -ISource/OpenEXR -ISource/OpenEXR/Half -ISource/OpenEXR/Iex -ISource/OpenEXR/IlmImf -ISource/OpenEXR/IlmThread -ISource/OpenEXR/Imath -ISource/OpenEXR/IexMath -ISource/LibRawLite -ISource/LibRawLite/dcraw -ISource/LibRawLite/internal -ISource/LibRawLite/libraw -ISource/LibRawLite/src -ISource/LibWebP -ISource/LibJXR -ISource/LibJXR/common/include -ISource/LibJXR/image/sys -ISource/LibJXR/jxrgluelib -fPIC -c Source/ZLib/inffast.c -o Source/ZLib/inffast.o
Source/ZLib/gzlib.c:252:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */
        ^
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
Source/ZLib/gzlib.c:252:9: note: did you mean 'fseek'?
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/include/stdio.h:162:6: note: 'fseek' declared here
int      fseek(FILE *, long, int);
         ^
Source/ZLib/gzlib.c:258:24: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        state->start = LSEEK(state->fd, 0, SEEK_CUR);
                       ^
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
Source/ZLib/gzlib.c:359:9: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
        ^
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
Source/ZLib/gzlib.c:400:15: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
              ^
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
Source/ZLib/gzlib.c:496:14: error: implicit declaration of function 'lseek' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    offset = LSEEK(state->fd, 0, SEEK_CUR);
             ^
Source/ZLib/gzlib.c:14:17: note: expanded from macro 'LSEEK'
#  define LSEEK lseek
                ^
5 errors generated.
Source/ZLib/gzread.c:35:15: error: implicit declaration of function 'read' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = read(state->fd, buf + *have, get);

I have a patch for this, which I will put up as a PR on GitHub shortly, which involves adding necessary headers and inlining a function to get this to compile.

Change History (4)

comment:1 Changed 4 years ago by mdave (David Moxey)

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

Keywords: bigsur catalina haspatch added

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

Cc: AlAnMikhayloff added

Has duplicate #62107.

comment:4 Changed 4 years ago by mdave (David Moxey)

Owner: set to mdave
Resolution: fixed
Status: newclosed

In 500bcc9ff6e2f0f7ef4e4c0d3415a3b0ea48ef8d/macports-ports (master):

freeimage: fix build failure due to C99 implicit declaration

Fixes: #61790

Note: See TracTickets for help on using tickets.