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: Solaris 8 declares gethostname().
View: 1257687
Superseder:
Assigned To: Nosy List: BreamoreBoy, dlr, georg.brandl, jbostock, r.david.murray
Priority: normal Keywords:

Created on 2003-11-06 08:09 by jbostock, last changed 2010-09-05 02:32 by r.david.murray. This issue is now closed.

Messages (7)
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.
History
Date User Action Args
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