Bug 703294

Summary: Ghostscript fails to compile against Android NDK's cdefs.h
Product: Ghostscript Reporter: Peter Cherepanov <sphinx.pinastri>
Component: Build ProcessAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal CC: fred.ross-perry
Priority: P4    
Version: master   
Hardware: Android Tablet   
OS: Android   
Customer: Word Size: ---
Attachments: Proposed fix patch

Description Peter Cherepanov 2020-12-19 06:26:04 UTC
The Android NDK's version of cdefs.h defines __printflike as 

#define __printflike(x, y) __attribute__((__format__(printf, x, y)))

which is valid as per https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-format-function-attribute but which conflicts with the redefinition of printf in gsio.h . The definition within the codebase uses __printf__ as the archetype to dodge this issue, but system definitions may not follow this convention.
Comment 1 Ray Johnston 2020-12-19 20:11:41 UTC
Assigning to Chris as a build issue, but we may have other Android developers
take (Fred?).
Comment 2 Fred Ross-Perry 2020-12-19 20:53:36 UTC
I'm curios as to why gsio.h does

   #undef printf
   #define printf Function._printf_.unavailable

as opposed to something like

   #undef printf
   #define printf(...) (0)
Comment 3 Ray Johnston 2020-12-19 21:33:50 UTC
In response to Fred: Ghostscript wants use of 'printf' to cause a compile
error since we want everything to funnel through dprintf or eprintf so that
the stdout and stderr output can be captured by the gs stdio callbacks.
Comment 5 Chris Liddell (chrisl) 2021-02-15 14:55:56 UTC
Patch applied:

https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=28d3245fbaff

Thanks.