[zjshao@master Python-3.5.2]$ make gcc -pthread -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -IInclude -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c In file included from Include/Python.h:65:0, from ./Programs/python.c:3: Include/pytime.h:24:4: error: #error "_PyTime_t need signed 64-bit integer type" # error "_PyTime_t need signed 64-bit integer type" ^~~~~ In file included from Include/Python.h:50:0, from ./Programs/python.c:3: Include/pytime.h:70:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds); ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ Include/pytime.h:78:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns); ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ In file included from Include/Python.h:65:0, from ./Programs/python.c:3: Include/pytime.h:82:43: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t, ^~~~~~~~~ Include/pytime.h:88:48: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t, ^~~~~~~~~ Include/pytime.h:93:44: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t); ^~~~~~~~~ In file included from Include/Python.h:50:0, from ./Programs/python.c:3: Include/pytime.h:96:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t, ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ In file included from Include/Python.h:65:0, from ./Programs/python.c:3: Include/pytime.h:96:46: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t, ^~~~~~~~~ In file included from Include/Python.h:50:0, from ./Programs/python.c:3: Include/pytime.h:100:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t, ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ In file included from Include/Python.h:65:0, from ./Programs/python.c:3: Include/pytime.h:100:46: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t, ^~~~~~~~~ Include/pytime.h:105:52: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t); ^~~~~~~~~ Include/pytime.h:111:35: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t, ^~~~~~~~~ Include/pytime.h:116:43: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(int) _PyTime_AsTimeval_noraise(_PyTime_t t, ^~~~~~~~~ In file included from Include/Python.h:50:0, from ./Programs/python.c:3: Include/pytime.h:131:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void); ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ Include/pytime.h:140:12: error: unknown type name ‘_PyTime_t’ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void); ^ Include/pyport.h:768:34: note: in definition of macro ‘PyAPI_FUNC’ # define PyAPI_FUNC(RTYPE) RTYPE ^~~~~ In file included from Include/Python.h:65:0, from ./Programs/python.c:3: Include/pytime.h:156:5: error: unknown type name ‘_PyTime_t’ _PyTime_t *t, ^~~~~~~~~ Include/pytime.h:168:5: error: unknown type name ‘_PyTime_t’ _PyTime_t *t, ^~~~~~~~~ In file included from Include/Python.h:77:0, from ./Programs/python.c:3: Include/unicodeobject.h:65:0: warning: "Py_USING_UNICODE" redefined #define Py_USING_UNICODE In file included from Include/Python.h:8:0, from ./Programs/python.c:3: /usr/local/include/python2.7/pyconfig.h:962:0: note: this is the location of the previous definition #define Py_USING_UNICODE 1 In file included from Include/Python.h:77:0, from ./Programs/python.c:3: Include/unicodeobject.h:71:0: warning: "Py_UNICODE_SIZE" redefined #define Py_UNICODE_SIZE SIZEOF_WCHAR_T In file included from Include/Python.h:8:0, from ./Programs/python.c:3: /usr/local/include/python2.7/pyconfig.h:959:0: note: this is the location of the previous definition #define Py_UNICODE_SIZE 2 In file included from Include/Python.h:77:0, from ./Programs/python.c:3: Include/unicodeobject.h:92:0: warning: "PY_UNICODE_TYPE" redefined #define PY_UNICODE_TYPE wchar_t In file included from Include/Python.h:8:0, from ./Programs/python.c:3: /usr/local/include/python2.7/pyconfig.h:950:0: note: this is the location of the previous definition #define PY_UNICODE_TYPE unsigned short make: *** [Programs/python.o] Error 1 [zjshao@master Python-3.5.2]$
#ifdef PY_INT64_T /* _PyTime_t: Python timestamp with subsecond precision. It can be used to store a duration, and so indirectly a date (related to another date, like UNIX epoch). */ typedef PY_INT64_T _PyTime_t; #define _PyTime_MIN PY_LLONG_MIN #define _PyTime_MAX PY_LLONG_MAX #else # error"_PyTime_t need signed 64-bit integer type" #endif
可见,预处理器报错的原因在于没有定义宏PY_INT64_T。
那再去找PY_INT64_T定义的地方(pyport.h):
1 2 3 4 5 6 7 8 9 10 11 12
/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the * integer implementation, when 30-bit digits are enabled. */ #ifdef int64_t #define HAVE_INT64_T 1 #endif