Issue 1191065: socketmodule.c's recvfrom on OSF/1 4.0 (original) (raw)

Compilation of Modules/socketmodule.c fails on OSF/1 4.0 with GCC versions 3.1 and 3.2. The error message is: python/dist/src/Modules/socketmodule.c:2139:1: directives may not be used inside a macro argument Line 2139 is in function sock_recvfrom(). The problem is that the function recvfrom() on the machine I use is a macro and the parameters for it are pieced together by use of #if instructions to the preprocessor, similar to the following code:

#include <stdio.h> #define macro(a, b) printf("Test: %d %d\n", a, b) int main(int argc, char** argv) { macro(1, 2); // works macro(1, #if defined(SOMETHING) 1 // error message here with older GCC #else 2 #endif ); return 0; }

This small test compiles with GCC 3.4, but with none of 2.95.3, 3.1, or 3.2.

The problem was in Python 2.3.4, 2.4.1 and CVS HEAD.

The attached patch (against CVS HEAD) fixes the problem by pulling the "#if"s out of the parameter list. Not as nice as before, but it works for me.