Bug 89356 - compilation error on AIX 6.1 (implicit declaration of function 'getline')
Summary: compilation error on AIX 6.1 (implicit declaration of function 'getline')
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other AIX
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-27 09:44 UTC by Michael Haubenwallner
Modified: 2015-03-07 01:57 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
define _GETDELIM for getline() on AIX (2.98 KB, patch)
2015-02-27 09:45 UTC, Michael Haubenwallner
Details | Splinter Review

Description Michael Haubenwallner 2015-02-27 09:44:11 UTC
And the last one for compiling current git-master with gcc on AIX:

/.../cairo-9999/perf/cairo-analyse-trace.c: In function 'read_excludes':
/.../cairo-9999/perf/cairo-analyse-trace.c:287: error: implicit declaration of function 'getline'
Makefile:952: recipe for target 'cairo-analyse-trace.o' failed
make[4]: *** [cairo-analyse-trace.o] Error 1
Comment 1 Michael Haubenwallner 2015-02-27 09:45:43 UTC
Created attachment 113863 [details] [review]
define _GETDELIM for getline() on AIX

Thanks!
Comment 2 Bryce Harrington 2015-03-04 23:51:50 UTC
Hi Michael,

Thanks for the patch to fix this compilation issue.  Offhand this looks fine, although I wonder if the define could be placed in a shared header or something rather than defined in each .c file.

However, I'd like to understand why exactly this define makes it work.  Can you point me at the code or an explanation of what _GETDELIM causes to happen on AIX?
Comment 3 Michael Haubenwallner 2015-03-05 09:39:04 UTC
The explanation is quite simple: AIX 6.1 <stdio.h> contains these lines:

  #ifdef _GETDELIM
  extern ssize_t  getdelim(char **, size_t *, int, FILE *);
  extern ssize_t  getline(char **, size_t *, FILE *);
  #endif /* GETDELIM */

But the configure check for getline is on the library-level only, not on the compiler-level.

However, on AIX 7.1 these lines have changed a little:

  #ifndef _NOGETDELIM
  extern ssize_t  getdelim();
  extern ssize_t  getline();
  #endif /* _NOGETDELIM */

So actually this define is necessary for AIX 6.1 (cannot check for earlier versions), but not for AIX 7.1.

For moving this define into some shared header: Indeed the proper place would be "config.h" as a result of some extra configure check, but I doubt that's really worth the effort here - unless more platforms come up with a similar problem.
OTOH, gnulib does check for missing getdelim declaration as well: https://www.gnu.org/software/gnulib/manual/html_node/getdelim.html
Comment 4 Bryce Harrington 2015-03-05 23:14:42 UTC
I wonder if util/cairo-missing/cairo-missing.h would be a better location for this define.  That already is providing a getline reimplementation.

But unfortunately none of the affected utilities include any local headers, so there's not really a central place to put them that wouldn't risk introducing some side effects.  The solution you provided is minimal and safe of any side effects, so I agree we should go with that for now.  Besides, the utilities affected by this issue have a lot of redundancy between them already.
Comment 5 Bryce Harrington 2015-03-06 00:59:35 UTC
Thanks for the explanation, applied:
   f72bd7c..e9a615a  master -> master


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.