Summary: | build error with freetype-2.10.3: ./base/fapi_ft.c:129:1: error: expected declaration specifiers before ‘FF_alloc’ | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Lars Wendler <polynomial-c> |
Component: | Font API | Assignee: | Chris Liddell (chrisl) <chris.liddell> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | chris.liddell, chrischavez, sam |
Priority: | P4 | ||
Version: | 9.53.3 | ||
Hardware: | PC | ||
OS: | Linux | ||
Customer: | Word Size: | --- | |
Attachments: | build.log |
Description
Lars Wendler
2020-10-12 12:08:00 UTC
It seems like FT_CALLBACK_DEF macro has been changed to be internal to freetype only: https://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=bb66c8d8cf1eb86309273d7c53c44522d35941d4 MacPorts recently encountered this problem (https://trac.macports.org/ticket/61306), since it builds Ghostscript with a separately-maintained build of freetype (which it just updated to 2.10.3), rather than the one bundled with Ghostscript. It is indeed because the FT_CALLBACK_DEF macro was moved from <freetype/config/ftconfig.h> to a private, non-installed header <freetype/internal/compiler-macros.h>. The important error observed using clang: ./base/fapi_ft.c:129:1: error: expected function body after function declarator FF_alloc(FT_Memory memory, long size) ^ clang mistakes FT_CALLBACK_DEF(void *) on the previous line for the function declarator, and '^' is where it expects the opening '{'. One workaround is to define FT_CALLBACK_DEF directly in fapi_ft.c: --- base/fapi_ft.c.orig +++ base/fapi_ft.c @@ -124,6 +124,14 @@ static void delete_inc_int_info(gs_fapi_server * a_server, FT_IncrementalRec * a_inc_int_info); + +#ifndef FT_CALLBACK_DEF +#ifdef __cplusplus +#define FT_CALLBACK_DEF( x ) extern "C" x +#else +#define FT_CALLBACK_DEF( x ) static x +#endif +#endif FT_CALLBACK_DEF(void *) FF_alloc(FT_Memory memory, long size) I've asked the freetype developers for some guidance on the appropriate fix for this (FT_CALLBACK_DEF seems like the right thing to use when defining a callback for freetype!). At the moment, there seems to be some uncertainty, and the developer who those changes to freetype has not actually replied. Once I get that guidance, I'll commit a fix based on it. Well, over a week, and no reply from the developer that actually made that change to Freetype, so I've gone ahead and committed the "obvious" change: https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=41ef9a0bc36b I still think it seems bonkers to have a macro for declaring callbacks that is inaccessible for code that wants to define callbacks.... oh well. |