Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Differing definitions of swab() in unistd.h and stdlib.h

68 views
Skip to first unread message

David Kirkby

unread,
Aug 24, 2010, 2:56:54 PM8/24/10
to
Threre's a plotting package called matplotlib

http://matplotlib.sourceforge.net/

Version 0.98 is used in the Sage maths project

http://www.sagemath.org/

The latest release of matplot lib is 1.0, but we can't upgrade to 1.0,
as there's a conflict of header files

/usr/include/stdlib.h:144: error: declaration of C function ‘void
swab(const char*, char*, ssize_t)’ conflicts with
/usr/include/unistd.h:496: error: previous declaration ‘void
swab(const void*, void*, ssize_t)’ here
error: command 'gcc' failed with exit status 1
Error building matplotlib package.


It appears Solaris has two different definitions of swab(). If one
reads the header files, it explains why. This is from stdlib.h, but no
doubt similar exists on unistd.h

===================================================
/*
* swab() has historically been in <stdlib.h> as delivered from AT&T
* and continues to be visible in the default compilation environment.
* As of Issue 4 of the X/Open Portability Guides, swab() was declared
* in <unistd.h>. As a result, with respect to X/Open namespace the
* swab() declaration in this header is only visible for the XPG3
* environment.
*/
#if (defined(__EXTENSIONS__) || \
(!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
(!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !
defined(_XPG4)))
#ifndef _SSIZE_T
#define _SSIZE_T
#if defined(_LP64) || defined(_I32LPx)
typedef long ssize_t; /* size of something in bytes or -1 */
#else
typedef int ssize_t; /* (historical version) */
#endif
#endif /* !_SSIZE_T */

extern void swab(const char *, char *, ssize_t);
#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

====================================================

Does anyone know how to get around this? The Matplot lib developers
have added this code in version 1.0, but it does not work.

================================================
// Prevent multiple conflicting definitions of swab from stdlib.h and
unistd.h
#if defined(__sun) || defined(sun)
#if defined(_XPG4)
#undef _XPG4
#endif
#if defined(_XPG3)
#undef _XPG3
#endif
#endif
=================================================

That simply does not work. You can see a bit more about this at

http://trac.sagemath.org/sage_trac/ticket/9221

Does anyone know what the matplot lib developers might be doing wrong?
Clearly there is no harm in having both stdlib.h and unistd.h in the
same file, but I assume somehow they have set something which exposes
both versions.

We would like to update matplot lib in Sage, but until the Solaris
issue is sorted out, it can't happen.

Any ideas, Dave ??

Ian Collins

unread,
Aug 24, 2010, 4:01:27 PM8/24/10
to
On 08/25/10 06:56 AM, David Kirkby wrote:

<snip>

> ====================================================
>
> Does anyone know how to get around this? The Matplot lib developers
> have added this code in version 1.0, but it does not work.
>
> ================================================
> // Prevent multiple conflicting definitions of swab from stdlib.h and
> unistd.h
> #if defined(__sun) || defined(sun)
> #if defined(_XPG4)
> #undef _XPG4
> #endif
> #if defined(_XPG3)
> #undef _XPG3
> #endif
> #endif
> =================================================
>
> That simply does not work. You can see a bit more about this at

I assume they have __EXTENSIONS__ (the left side of the OR) defined
somewhere.

--
Ian Collins

0 new messages