This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/4850: GCC should implement pragma redefine_extname bind
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/4850: GCC should implement pragma redefine_extname bind
- From: Martin von Loewis <loewis at informatik dot hu-berlin dot de>
- Date: Sat, 10 Nov 2001 16:21:36 +0100 (MET)
>Number: 4850
>Category: c
>Synopsis: GCC should implement pragma redefine_extname bind
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Nov 10 07:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Martin v. Loewis <loewis@informatik.hu-berlin.de
>Release: 3.0.2 20011014 (prerelease)
>Organization:
>Environment:
System: SunOS pandora 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-Enterprise
Architecture: sun4
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../configure --enable-shared --enable-threads --with-cpu=v8 --with-gnu-ld --with-gnu-as --enable-version-specific-runtime-libs
>Description:
In Solaris 8, Sun uses a pragma to rename symbols in a number of
system headers. E.g. sys/socket.h contains
#ifdef _XPG4_2
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname bind __xnet_bind
#pragma redefine_extname connect __xnet_connect
#pragma redefine_extname recvmsg __xnet_recvmsg
#pragma redefine_extname sendmsg __xnet_sendmsg
#pragma redefine_extname sendto __xnet_sendto
#pragma redefine_extname socket __xnet_socket
#pragma redefine_extname socketpair __xnet_socketpair
#pragma redefine_extname getsockopt __xnet_getsockopt
#else /* __PRAGMA_REDEFINE_EXTNAME */
#define bind __xnet_bind
#define connect __xnet_connect
#define recvmsg __xnet_recvmsg
#define sendmsg __xnet_sendmsg
#define sendto __xnet_sendto
#define socket __xnet_socket
#define socketpair __xnet_socketpair
#define getsockopt __xnet_getsockopt
#endif /* __PRAGMA_REDEFINE_EXTNAME */
#endif /* _XPG4_2 */
When compiling this header, in particular with g++, the macro definition
may cause problems. These problems could be avoided if either g++
implemented redefine_extname, or else if all those headers would be
fixincluded.
>How-To-Repeat:
Compile the following on Solaris 8 with g++ 3:
namespace foo{
int socket = 1;
}
#include <sys/socket.h>
int main()
{
foo::socket = 2;
}
This fails with the error
a.cc:9: `__xnet_socket' undeclared in namespace `foo'
Part of the problem is that g++ 3 indirectly defines _XPG4_2.
>Fix:
The work-around is to manually delete all the redefine sections in
the g++ headers. As a drawback, the redefining does not happen in
this approach.
>Release-Note:
>Audit-Trail:
>Unformatted: