Article View: gnu.gcc.help
Article #50422I don't understand g++ configuration problem
From: Mark-Jason Dominus
Date: Tue, 28 Sep 1993 20:19
Date: Tue, 28 Sep 1993 20:19
473 lines
7582 bytes
7582 bytes
I cannot compile the following program:
--- BEGIN sl.C
#include <string.h>
int main(void)
{
int q = strlen("foo");
printf("%d\n", q);
}
--- END sl.C
After preprocessing on my machine with
g++-2.4 -v -E sl.C > sl.i >[2] ppo
the preprocessor standard error output is:
--- BEGIN ppo
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/specs
gcc version 2.4.5
/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -D__GCC_NEW_VARARGS__ sl.C
GNU CPP version 2.4.5 (sparc)
--- END ppo
--- BEGIN /usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/specs
*asm:
%| %{fpic:-k} %{fPIC:-k}
*asm_final:
*cpp:
%{msparclite:-D__sparclite__} %{mv8:-D__sparc_v8__}
*cc1:
%{sun4:} %{target:}
*cc1plus:
*endfile:
*link:
%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} %{assert*}
*lib:
%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} %{g:-lg} %{a:/usr/lib/bb_link.o}
*startfile:
%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}
*switches_need_spaces:
*signed_char:
%{funsigned-char:-D__CHAR_UNSIGNED__}
*predefines:
-Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__
*cross_compile:
0
--- END /usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/specs
And the post-preprocessed source is
--- BEGIN sl.i
# 1 "sl.C"
# 1 "/usr/local/lib/g++-include/string.h" 1 3
# 1 "/usr/local/lib/g++-include/_G_config.h" 1 3
typedef long _G_clock_t;
typedef short _G_dev_t;
typedef long _G_fpos_t;
typedef int _G_gid_t;
typedef unsigned long _G_ino_t;
typedef unsigned short _G_mode_t;
typedef short _G_nlink_t;
typedef long _G_off_t;
typedef int _G_pid_t;
typedef int _G_ptrdiff_t;
typedef int _G_sigset_t;
typedef int _G_size_t;
typedef long _G_time_t;
typedef int _G_uid_t;
typedef unsigned short _G_wchar_t;
typedef int _G_ssize_t;
typedef char* _G_va_list;
# 5 "/usr/local/lib/g++-include/string.h" 2 3
extern "C" {
char* strcat(char*, const char*);
char* strchr(const char*, int);
int strcmp(const char*, const char*);
int strcoll(const char*, const char*);
char* strcpy(char*, const char*);
_G_size_t strcspn(const char*, const char*);
char* strdup(const char*);
_G_size_t strlen(const char*);
char* strncat(char*, const char*, _G_size_t );
int strncmp(const char*, const char*, _G_size_t );
char* strncpy(char*, const char*, _G_size_t );
char* strpbrk(const char*, const char*);
char* strrchr(const char*, int);
_G_size_t strspn(const char*, const char*);
char* strstr(const char*, const char *);
char* strtok(char*, const char*);
_G_size_t strxfrm(char*, const char*, _G_size_t );
char* index(const char*, int);
char* rindex(const char*, int);
}
# 1 "/usr/local/lib/g++-include/memory.h" 1 3
# 1 "/usr/local/lib/g++-include/stddef.h" 1 3
extern "C" {
# 1 "/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/include/stddef.h" 1 3
# 48 "/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/include/stddef.h" 3
typedef int ptrdiff_t;
typedef __wchar_t wchar_t;
# 195 "/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/include/stddef.h" 3
# 7 "/usr/local/lib/g++-include/stddef.h" 2 3
}
# 6 "/usr/local/lib/g++-include/memory.h" 2 3
extern "C" {
void* memalign (...) ;
void* memccpy (...) ;
void* memchr (...) ;
int memcmp (...) ;
void* memcpy (...) ;
void* memmove (...) ;
void* memset (...) ;
int ffs (...) ;
_G_size_t getpagesize (...) ;
void* valloc (...) ;
void bcopy (...) ;
int bcmp (...) ;
void bzero (...) ;
}
# 43 "/usr/local/lib/g++-include/string.h" 2 3
# 1 "sl.C" 2
int main(void)
{
int q = strlen("foo");
printf("%d\n", q);
}
--- END sl.i
Here's the verbose output from g++ when I try to compile it with
g++-2.4 -v sl.i -c >[2] co
--- BEGIN co
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/specs
gcc version 2.4.5
/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -D__GCC_NEW_VARARGS__ sl.i /usr/tmp/cca08215.i
GNU CPP version 2.4.5 (sparc)
/usr/local/lib/gcc-lib/sparc-sun-sunos4.3/2.4.5/cc1plus /usr/tmp/cca08215.i -quiet -dumpbase sl.cc -version -o /usr/tmp/cca08215.s
GNU C++ version 2.4.5 (sparc) compiled by GNU C version 2.4.5.
In file included from sl.i:1:
/usr/local/lib/g++-include/string.h:28: declaration of `int strlen (const char *)'
<built-in>:0: conflicts with built-in declaration `long unsigned int strlen (const char *)'
sl.C: In function `int main ()':
sl.C:7: warning: implicit declaration of function `printf'
--- END co
And no sl.o file is produced. My problem is with
/usr/local/lib/g++-include/string.h:28: declaration of `int strlen (const char *)'
<built-in>:0: conflicts with built-in declaration `long unsigned int strlen (const char *)'
. There's a comment in /usr/local/lib/g++-include/string.h that says:
// NOTE: If you get a error message from g++ that this declaration
// conflicts with a <built-in> declaration of strlen(), that usually
// indicates that __SIZE_TYPE__ is incorrectly defined by gcc.
// Fix or add SIZE_TYPE in the appropriate file in gcc/config/*.h.
size_t strlen(const char*);
size_t is #defined to be `_G_size_t', and _G_size_t' is typedeffed to
`int'. As nearly as I can tell, the type of `strlen' is hard-wired in
g++ to be `unsigned long int'. So the only option seems to be to change
the definition of _G_size_t to be `unsigned long int'.
However, I've looked at the source for our strlen and it really does
return `int', not `unsigned long int'. This is probably a deficiency in
our environment, but we'd prefer not to have to replace stlen. Our
vendor-supplied headers define size_t to be `int' and I'm reluctant to
mess with this.
I'm not sure how to proceed with this. In the meantime we can't use
g++-2.4 because of these type conflicts. g++ 2.3.3 is working fine for
us; I'm not sure what is really different.
What do you advise?
Technical Details
Message-ID:
<9309281647.AA08534@saul.cis.upenn.edu>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!cis.ohio-state.edu!saul.cis.upenn.edu!mjdShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,e753f81f14d4e1ba,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-09-28 14:05:39 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!cis.ohio-state.edu!saul.cis.upenn.edu!mjd From: mjd@saul.cis.upenn.edu (Mark-Jason Dominus) Newsgroups: gnu.gcc.help Subject: I don't understand g++ configuration problem Date: 28 Sep 1993 16:19:23 -0400 Organization: Martin Bormann's Cranial Splints Lines: 473 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <9309281647.AA08534@saul.cis.upenn.edu>