This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SIZEOF_SOCKET_T not defined
Type: compile error Stage: resolved
Components: Extension Modules, Interpreter Core Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, christian.heimes, dmalcolm, loewis, pitrou, tim.golden
Priority: normal Keywords: patch

Created on 2009-01-04 18:11 by skip.montanaro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
add-socketrepr.h-to-py3k.patch dmalcolm, 2010-04-23 17:03
sockdefine.patch pitrou, 2010-08-17 20:25
sockdefine2.patch pitrou, 2010-08-21 18:59
Messages (13)
msg79075 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2009-01-04 18:11
Compiling with Intel's icc I get lots of remarks like this:

    icc -c -fno-strict-aliasing -DNDEBUG -g  -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I../Include   -DPy_BUILD_CORE -o Parser/acceler.o ../Parser/acceler.c
    ../Include/longobject.h(35): remark #193: zero used for undefined preprocessing identifier "SIZEOF_SOCKET_T"
      #if SIZEOF_SOCKET_T <= SIZEOF_LONG
          ^

This is only defined in Modules/socketmodule.h.  It should probably be
defined somewhere else if it's to be referenced by longobject.h.

Skip
msg104027 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2010-04-23 17:03
I'm seeing this with gcc-4.4.3 with -Wall -Werror, leading to fatal errors trying to build an extension module against python 3.1

The references to SIZEOF_SOCKET_T within longobject.h appear to be just in the py3k branch, not trunk, and were added in r59009.  I'm marking this issue as python3, and as both "Interpreter Core" and "Extension Modules".

There didn't seem to be a natural place to put these types, so I'm attaching a patch against the py3k branch which adds a new public/installed header file: Include/socketrepr.h, specifically to contain them.   How does this look?
msg104029 - (view) Author: Dave Malcolm (dmalcolm) (Python committer) Date: 2010-04-23 17:08
> I'm seeing this with gcc-4.4.3 with -Wall -Werror, leading to fatal errors
> trying to build an extension module against python 3.1

Specifically, with gcc, I'm seeing this warning (trying to port SELinux Python support to Python3), which, with -Werror becomes fatal:
In file included from /usr/include/python3.1/Python.h:72,
                 from audit2why.c:1:
/usr/include/python3.1/longobject.h:36:5: error: "SIZEOF_SOCKET_T" is not defined
cc1: warnings being treated as errors
msg114149 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 19:24
We don't need a separate header file, the definitions can go into pyport.h instead.
msg114150 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 19:27
However, since this makes SOCKET_T public, it should probably be renamed to Py_SOCKET_T.
msg114157 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 20:08
After trying it out, pulling SOCKET in the Python headers brings complications under Windows, because you need to include <winsock2.h> which in turn breaks compilation of _pickle.c (duplicate definition of "FLOAT", "INT", etc.).

An alternative approach would be to define only SIZEOF_SOCKET_T in the standard headers (we don't actually need access to the SOCKET type to compute it, as the current hard-coding shows), and leave SOCKET_T in socketmodule.h.
msg114160 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 20:25
Here is a patch implementing the approach I proposed above.
It successfully removes warnings about casting SOCKET to long under 64-bit Windows.
msg114167 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-08-17 20:56
sockdefine.patch seems fine to me.
msg114186 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-08-17 22:30
Why is PyLong_FromSocket_t defined in a header file in the first place? The only caller is in socketmodule.c, and calling it elsewhere wouldn't work, anyway, since it relies on SOCKET_T being defined.

So -1 on the patch.
msg114187 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-17 22:31
> Why is PyLong_FromSocket_t defined in a header file in the first
> place? The only caller is in socketmodule.c, and calling it elsewhere
> wouldn't work, anyway, since it relies on SOCKET_T being defined.

I agree, but it was already like that, and I didn't want to change it.
msg114190 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-08-17 22:44
> I agree, but it was already like that, and I didn't want to change it.

This goes back to issue 1378. Christian, do you recall why you needed to add the helper macros to a header file? You said

# Added PyLong_FromSocket_t and PyLong_AsSocket_t to longobject.h 
# to get rid of some 64bit warnings

but I doubt that it really needed to live in the header file.
msg114544 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-21 18:59
This new patch takes the reverse approach and makes the function definitions (PyLong_FromSocket_t() and PyLong_AsSocket_t()) private to socketmodule.h. I will commit if no-one objects.
msg115171 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-28 20:55
Committed in r84347 (py3k) and r84348 (3.1).
History
Date User Action Args
2022-04-11 14:56:43adminsetgithub: 49085
2010-08-28 20:55:54pitrousetstatus: open -> closed
versions: - Python 2.7
messages: + msg115171

resolution: fixed
stage: patch review -> resolved
2010-08-21 18:59:15pitrousetfiles: + sockdefine2.patch

messages: + msg114544
2010-08-17 22:44:37loewissetnosy: + christian.heimes
messages: + msg114190
2010-08-17 22:31:51pitrousetmessages: + msg114187
2010-08-17 22:30:12loewissetmessages: + msg114186
2010-08-17 20:56:45brian.curtinsetmessages: + msg114167
2010-08-17 20:25:54pitrousetfiles: + sockdefine.patch

messages: + msg114160
2010-08-17 20:08:36pitrousetmessages: + msg114157
2010-08-17 19:27:06pitrousetnosy: + loewis
messages: + msg114150
2010-08-17 19:24:01pitrousetnosy: + tim.golden, brian.curtin, pitrou

messages: + msg114149
versions: + Python 2.7, - Python 3.3
2010-08-17 19:17:23dmalcolmlinkissue9629 superseder
2010-05-20 20:39:03skip.montanarosetnosy: - skip.montanaro
2010-04-23 17:08:24dmalcolmsetmessages: + msg104029
2010-04-23 17:03:07dmalcolmsetfiles: + add-socketrepr.h-to-py3k.patch

type: compile error
components: + Extension Modules, Interpreter Core
versions: + Python 3.1, Python 3.2, Python 3.3
keywords: + patch
nosy: + dmalcolm

messages: + msg104027
stage: patch review
2009-01-04 18:11:42skip.montanarocreate