Bug 703294 - Ghostscript fails to compile against Android NDK's cdefs.h
Summary: Ghostscript fails to compile against Android NDK's cdefs.h
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Build Process (show other bugs)
Version: master
Hardware: Android Tablet Android
: P4 normal
Assignee: Chris Liddell (chrisl)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-19 06:26 UTC by Peter Cherepanov
Modified: 2021-02-15 14:55 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Proposed fix patch (2.08 KB, patch)
2020-12-25 01:19 UTC, Peter Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.