[pycrypto] #include Python.h

Brent S. Elmer Ph.D. webe3vt at aim.com
Fri May 9 09:02:24 PDT 2014


I am trying to build pycrypto on AIX.  I am running into a problem.  It
seems to me that it is a problem with pycrypto.

On AIX, Python defines _LARGE_FILES to handle large files.  This causes
pycrypto not to compile.  The output looks like this:

"/usr/include/stdio.h", line 528.12: 1506-343 (S) Redeclaration of
fgetpos64 differs from previous declaration on line 323 of
"/usr/include/stdio.h".
"/usr/include/stdio.h", line 528.12: 1506-377 (I) The type "long long*"
of parameter 2 differs from the previous type "long* restrict".
"/usr/include/stdio.h", line 531.12: 1506-343 (S) Redeclaration of
fseeko64 differs from previous declaration on line 471 of
"/usr/include/stdio.h".
"/usr/include/stdio.h", line 531.12: 1506-377 (I) The type "long long"
of parameter 2 differs from the previous type "long".
"/usr/include/stdio.h", line 532.12: 1506-343 (S) Redeclaration of
fsetpos64 differs from previous declaration on line 325 of
"/usr/include/stdio.h".
"/usr/include/stdio.h", line 532.12: 1506-377 (I) The type "const long
long*" of parameter 2 differs from the previous type "const long*".
"/usr/include/stdio.h", line 533.16: 1506-343 (S) Redeclaration of
ftello64 differs from previous declaration on line 472 of
"/usr/include/stdio.h".
"/usr/include/stdio.h", line 533.16: 1506-050 (I) Return type "long
long" in redeclaration is not compatible with the previous return type
"long".
"/usr/include/unistd.h", line 171.17: 1506-343 (S) Redeclaration of
lseek64 differs from previous declaration on line 169 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 171.17: 1506-050 (I) Return type "long
long" in redeclaration is not compatible with the previous return type
"long".
"/usr/include/unistd.h", line 171.17: 1506-377 (I) The type "long long"
of parameter 2 differs from the previous type "long".
"/usr/include/sys/lockf.h", line 64.20: 1506-343 (S) Redeclaration of
lockf64 differs from previous declaration on line 62 of
"/usr/include/sys/lockf.h".
"/usr/include/sys/lockf.h", line 64.20: 1506-377 (I) The type "long
long" of parameter 3 differs from the previous type "long".
"/usr/include/unistd.h", line 809.33: 1506-343 (S) Redeclaration of
ftruncate64 differs from previous declaration on line 807 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 809.33: 1506-377 (I) The type "long long"
of parameter 2 differs from the previous type "long".
"/usr/include/unistd.h", line 845.33: 1506-343 (S) Redeclaration of
truncate64 differs from previous declaration on line 843 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 845.33: 1506-377 (I) The type "long long"
of parameter 2 differs from the previous type "long".
"/usr/include/unistd.h", line 862.33: 1506-343 (S) Redeclaration of
pread64 differs from previous declaration on line 859 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 862.33: 1506-377 (I) The type "long long"
of parameter 4 differs from the previous type "long".
"/usr/include/unistd.h", line 863.33: 1506-343 (S) Redeclaration of
pwrite64 differs from previous declaration on line 860 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 863.33: 1506-377 (I) The type "long long"
of parameter 4 differs from the previous type "long".
"/usr/include/unistd.h", line 942.25: 1506-343 (S) Redeclaration of
fclear64 differs from previous declaration on line 939 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 942.25: 1506-050 (I) Return type "long
long" in redeclaration is not compatible with the previous return type
"long".
"/usr/include/unistd.h", line 942.25: 1506-377 (I) The type "long long"
of parameter 2 differs from the previous type "long".
"/usr/include/unistd.h", line 943.25: 1506-343 (S) Redeclaration of
fsync_range64 differs from previous declaration on line 940 of
"/usr/include/unistd.h".
"/usr/include/unistd.h", line 943.25: 1506-377 (I) The type "long long"
of parameter 3 differs from the previous type "long".


The problem is that the pycrypto source files do not #include "Python.h"
before all other includes.  In general, you would always want to include
all standard libraries first(i.e. #include <string.h> ...)  However,
with Python.h this is bad.  The reason is that Python.h includes
pyconfig.h which has defines intended to define system level compiler
directives for the particular platform.  These would of course need to
be defined before all standard header files otherwise, the standard
header files before the Python.h include would not have the system
defines and the standard header files after the Python.h include would.
That causes the errors as demonstrated above.  If you look at all of the
source files in the Python sources, you will see that they all include
Python.h for this very reason.

I am going to fix this in my copy of pycrypto so that it will build.  I
would suggest that this is also done upstream.

Brent



More information about the pycrypto mailing list