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: pyport.h redeclares gethostname() if SOLARIS is defined
Type: compile error Stage: test needed
Components: Build Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: 1257687 Superseder:
Assigned To: Nosy List: BreamoreBoy, dlr, georg.brandl, jbostock, mst, r.david.murray
Priority: normal Keywords:

Created on 2003-11-06 08:09 by jbostock, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (11)
msg18908 - (view) Author: James Bostock (jbostock) Date: 2003-11-06 08:09
The file pyport.h contains the lines:

#ifdef SOLARIS
/* Unchecked */
extern int gethostname(char *, int);
#endif

However, Solaris already defines gethostname() 
in /usr/include/unistd.h [I only have access to Solaris 
2.6 and 2.8 so I can't vouch for other versions].

This in iteself is not a problem. However, under 
Python2.3, pyconfig.h defines _XOPEN_SOURCE and 
_XOPEN_SOURCE_EXTENDED which cause (indirectly) 
the following prototype to be selected from unitstd.h:

extern int gethostname(char *, size_t);

Since size_t is an unsigned char, a compiler error 
message is generated (both by the native compiler and 
gcc) saying that the function has been redefined.
This means that no python program can be compiled if 
SOLARIS is #defined.

I imagine that the above code from pyport.h is only 
applicable to an earlier version of Solaris than 2.6, and 
so should either be removed or qualified somehow.
msg18909 - (view) Author: James Bostock (jbostock) Date: 2003-11-26 18:43
Logged In: YES 
user_id=902503

"Since size_t is an unsigned char" should read "Since size_t is 
an unsigned int".
msg18910 - (view) Author: Daniel L. Rall (dlr) Date: 2005-12-19 21:19
Logged In: YES 
user_id=6606

I can verify this issue on Solaris 10 (SunOS 5.10).  Not
only does this code seem unnecessary, but there is no
configury nor make magic which _can_ ever set the SOLARIS
preprocessor define.  If I run 'make' as follows, I can
trigger a hard compilation error:

[Python-2.4.2]$ make CFLAGS='$(BASECFLAGS) $(OPT)
-DSOLARIS=true'
...
In file included from ./Include/Python.h:55,
                 from Objects/complexobject.c:8:
./Include/pyport.h:382: error: conflicting types for
'gethostname'
/usr/include/unistd.h:319: error: previous declaration of
'gethostname' was here./Include/pyport.h:382: error:
conflicting types for 'gethostname'
/usr/include/unistd.h:319: error: previous declaration of
'gethostname' was here*** Error code 1
make: Fatal error: Command failed for target
`Objects/complexobject.o'

I recommend removing this snippet from pyport.h:

--- Include/pyport.h	(revision 41772)
+++ Include/pyport.h	(working copy)
@@ -372,11 +372,6 @@
 in platform-specific #ifdefs.
 **************************************************************************/
 
-#ifdef SOLARIS
-/* Unchecked */
-extern int gethostname(char *, int);
-#endif
-
 #ifdef __BEOS__
 /* Unchecked */
 /* It's in the libs, but not the headers... - [cjh] */
msg18911 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-20 18:34
Logged In: YES 
user_id=849994

Closed #1257687 as a duplicate.
msg114296 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-18 23:10
I'll close in a couple of weeks unless someone states this is still a problem.
msg115600 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-04 18:42
No reply to msg114296.
msg115622 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-09-05 02:32
I'm not sure it was appropriate to close this bug in isolation without confirmation that it is no longer a problem, but I'm also guessing that it is in fact no longer a problem due to the fix to issue 1759169.  So because that seems likely I'm leaving it closed as out of date.
msg216297 - (view) Author: Michael Stahl (mst) Date: 2014-04-15 14:32
we carry a patch in LibreOffice for exactly this problem:

http://cgit.freedesktop.org/libreoffice/core/tree/external/python3/python-3.3.0-i42553.patch.2

this was found many years ago in OOo:
https://issues.apache.org/ooo/show_bug.cgi?id=42553

there is at least one file in the LO code which includes pyport.h
(which i have just verified via generated header dependencies),
and the LO build system globally defines a SOLARIS macro
on that platform, so there's a real-world problem caused by this.

so if you could re-open this and merge that patch we could
finally get rid of it on our side; there doesn't appear to be
a downside to me since according to this bug report
the prototype is wrong for Solaris 2.6 already, and older
versions ought to have died out by now.
msg216896 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-04-20 04:10
Can you confirm that this is really still a problem, despite the Solaris cleanup in issue 1759169?
msg216916 - (view) Author: James Bostock (jbostock) Date: 2014-04-20 19:32
I have not compiled Python from source code for many years and no longer have access to Solaris machines so I cannot say whether or not this is still a problem.
msg216967 - (view) Author: Michael Stahl (mst) Date: 2014-04-21 19:55
(note that i haven't used any Solaris myself since 2011)

* the #ifdef SOLARIS block still exists in current hg checkout
* according to comment http://bugs.python.org/msg18910 the SOLARIS
  macro can not be defined during a build of python itself, so:
  - the #ifdef SOLARIS block does not break build of python itself
  - the #ifdef SOLARIS block has no useful purpose
* the #ifdef SOLARIS block is in a public header that may be
  included by _other_projects_' source files, and if those other
  projects happen to define a SOLARIS macro then they get the breakage
  (as the OOo patch demonstrates)
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39512
2014-04-21 19:55:32mstsetmessages: + msg216967
2014-04-20 19:32:58jbostocksetmessages: + msg216916
2014-04-20 04:10:58r.david.murraysetmessages: + msg216896
2014-04-15 14:32:56mstsetnosy: + mst
messages: + msg216297
2010-09-05 02:32:45r.david.murraysetnosy: + r.david.murray
messages: + msg115622
2010-09-04 18:42:17BreamoreBoysetstatus: pending -> closed
resolution: out of date
messages: + msg115600
2010-08-18 23:10:06BreamoreBoysetstatus: open -> pending
nosy: + BreamoreBoy
messages: + msg114296

2009-02-13 04:50:50ajaksu2setversions: + Python 2.6, - Python 2.4
dependencies: + Solaris 8 declares gethostname().
type: compile error
components: + Build, - None
stage: test needed
2003-11-06 08:09:52jbostockcreate