other/1865: struct utsname members are different for g++ and gcc
jnance@numeritech.com
jnance@numeritech.com
Sat Feb 3 16:06:00 GMT 2001
>Number: 1865
>Category: other
>Synopsis: struct utsname members are different for g++ and gcc
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 03 16:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: James Lewis Nance
>Release: 2.97 20010202 (experimental)
>Organization:
>Environment:
System: Linux bessie 2.4.1 #10 Tue Jan 30 22:06:40 EST 2001 i586 unknown
Architecture: i586
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/home/jlnance/gcctemp
>Description:
The definition of struct utsname is different depending on on whether
one uses gcc or g++ to compile the program:
bessie> $HOME/gcctemp/bin/gcc -o /dev/null -c $HOME/y.c
bessie> $HOME/gcctemp/bin/g++ -o /dev/null -c $HOME/y.c
/usr/local/home/jlnance/y.c: In function `void badfun(char**)':
/usr/local/home/jlnance/y.c:9: `struct utsname' has no member named
`__domainname'
I looked in the header files and it looks like this could be
caused by __USE_GNU getting defined somehow for gcc but not for g++:
struct utsname
{
[snip]
#if _UTSNAME_DOMAIN_LENGTH - 0
/* Name of the domain of this node on the network. */
# ifdef __USE_GNU
char domainname[_UTSNAME_DOMAIN_LENGTH];
# else
char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
};
>How-To-Repeat:
cat >y.c <<EOF
#include <sys/utsname.h>
void badfun(char * *aDomain)
{
struct utsname buf;
char *domainname = 0;
/*domainname = buf.domainname;*/ /* Works with g++ */
domainname = buf.__domainname; /* Works with gcc */
}
EOF
gcc -o /dev/null -c y.c
g++ -o /dev/null -c y.c
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list