[Boost-bugs] [Boost C++ Libraries] #10122: Recent Python versions trigger compiler error on AIX when compiling modules/regex.c: conflicting types for 'fgetpos64'

Subject: [Boost-bugs] [Boost C++ Libraries] #10122: Recent Python versions trigger compiler error on AIX when compiling modules/regex.c: conflicting types for 'fgetpos64'
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-13 13:08:43


#10122: Recent Python versions trigger compiler error on AIX when compiling
modules/regex.c: conflicting types for 'fgetpos64'
-------------------------------------------------+-------------------------
 Reporter: Michael Haubenwallner | Owner:
  <michael.haubenwallner@…> | vladimir_prus
     Type: Patches | Status: new
Milestone: To Be Determined | Component: build
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
-------------------------------------------------+-------------------------
 Since bugs.python.org/issue11184, recent Python releases (like
 Python-2.7.6) now have proper large-file support for AIX, defining
 _LARGE_FILES in <pyconfig.h>, exposed to the user via <Python.h>.

 Now, bootstrapping boost.build for AIX using such a Python release causes
 the compiler errors shown in attached files when compiling
 modules/regex.c.

 The problem with modules/regex.c is:
 * `modules/regex.c` first includes `"../mem.h"`
 * `mem.h` includes `<stdlib.h>` includes `<standards.h>`
 Due to nothing relevant being defined yet, `<standards.h>` defines
 `_LARGE_FILE_API`
 * `stdlib.h` includes `<sys/types.h>`
 * `sys/types.h` does {`typedef long fpos_t;`}, because `_LARGE_FILES` is
 not defined
 If `_LARGE_FILES` were defined before, `sys/types.h` would have done
 {`typedef long long fpos_t;`} here.
 * `sys/types.h` does {`typedef long long fpos64_t;`} due to
 `_LARGE_FILE_API` being defined
 * `modules/regex.c` includes `"../native.h"` includes `"function.h"`
 includes `"frames.h"` includes `"lists.h"` includes `<Python.h>` includes
 [`<pyconfig.h>`, `<stdio.h>`]
 * `pyconfig.h` defines `_LARGE_FILES`
 * `stdio.h` does not redefine the `fpos_t` things
 * `stdio.h` does {`#define fgetpos fgetpos64`} due to `_LARGE_FILES` being
 defined now
 * `stdio.h` declares {`extern int fgetpos(FILE*,fpos_t);`}, but remember
 `fgetpos` is defined to `fgetpos64`
 * `stdio.h` declares {`extern int fgetpos64(FILE*,fpos64_t);`} due to
 `_LARGE_FILE_API` being defined

 This problem is the same for the other functions the compilers yell about.

 Also, the same errors occur with current git master.

 For the fix:
 It is important to have all the ABI specific precompiler macros being
 defined before including any system header. Actually, the first thing
 `"jam.h"` does is to include `<Python.h>`. But with `modules/regex.c`
 first including `"../mem.h"` including `<stdlib.h>`, this rule is not
 followed. So the fix here is:
 {{{
 --- a/src/engine/mem.h
 +++ b/src/engine/mem.h
 @@ -8,6 +8,8 @@
  #ifndef BJAM_MEM_H
  #define BJAM_MEM_H

 +#include "jam.h"
 +
  #ifdef OPT_BOEHM_GC

      /* Use Boehm GC memory allocator. */
 }}}

 While the fix for this very problem is quite simple, it doesn't look like
 if `<Python.h>` being included first everywhere else in
 build.git/src/engine is on purpose actually...

 Thank you!

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10122>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC