Bug 4850 - GCC should implement pragma redefine_extname bind
Summary: GCC should implement pragma redefine_extname bind
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.0.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-10 07:26 UTC by Martin v. Loewis
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin v. Loewis 2001-11-10 07:26:00 UTC
	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.

Release:
3.0.2 20011014 (prerelease)

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

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.
Comment 1 Martin v. Loewis 2001-11-10 07:26:00 UTC
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.
Comment 2 Richard Henderson 2002-04-26 01:38:59 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Done for gcc 3.1.