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.
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.
State-Changed-From-To: open->closed State-Changed-Why: Done for gcc 3.1.