Bug#100103: stdio.h is incomplete (strlen and others are missing)
Package: gcc-3.0
Version: 1:3.0-0pre010526
Severity: normal
Hi
Compiling the following short program
#include <stdio.h>
int main (int argc, char** argv) {
const char a[14] = "Hello World.\0";
printf("length of a = %s is %i\n", a, strlen(a));
return 0;
}
with gcc-3.0 yields a warning: "implicit declaration of function
`strlen'" although strlen is declared in stdio.h according to
the man page. The problem is, that gcc-3.0 does not read
/usr/include/stdio.h, where strlen is declared but reads
/usr/lib/gcc-lib/i386-linux/3.0/include/stdio.h instead. In this
file, strlen (and others, e.g. strncpy) are not declared.
/usr/lib/gcc-lib/i386-linux/3.0/include comes before
/usr/include in the include path of gcc-3.0:
gcc-3.0 -Wall -g -v bug.c -o bug
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0 20010526 (Debian prerelease)
/usr/lib/gcc-lib/i386-linux/3.0/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ bug.c -quiet -dumpbase bug.c -g -Wall -version -o /tmp/ccdOKGjd.s
GNU CPP version 3.0 20010526 (Debian prerelease) (cpplib) (i386 Linux/ELF)
GNU C version 3.0 20010526 (Debian prerelease) (i386-linux)
compiled by GNU C version 3.0 20010526 (Debian prerelease).
ignoring nonexistent directory "/usr/i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i386-linux/3.0/include
/usr/include
End of search list.
bug.c: In function main':
bug.c:7: warning: implicit declaration of function strlen'
as --traditional-format -V -Qy -o /tmp/cc0fFqGm.o /tmp/ccdOKGjd.s
GNU assembler version 2.11.90.0.7 (i386-linux) using BFD version 2.11.90.0.7
/usr/lib/gcc-lib/i386-linux/3.0/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o bug /usr/lib/gcc-lib/i386-linux/3.0/../../../crt1.o /usr/lib/gcc-lib/i386-linux/3.0/../../../crti.o /usr/lib/gcc-lib/i386-linux/3.0/crtbegin.o -L/usr/lib/gcc-lib/i386-linux/3.0 -L/usr/lib/gcc-lib/i386-linux/3.0/../../.. /tmp/cc0fFqGm.o -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-linux/3.0/crtend.o /usr/lib/gcc-lib/i386-linux/3.0/../../../crtn.o
With gcc, this is not a problem: it just complains about strlen
not beeing defined, but with g++, this is a serious problem,
since it reports this as an error and stops compiling. (I am
using strlen in a C++ program.)
Regards,
Philipp
-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux herodot 2.4.3 #10 Die Apr 3 11:00:30 CEST 2001 i686
Versions of packages gcc-3.0 depends on:
ii binutils 2.11.90.0.7-2 The GNU assembler, linker and bina
ii cpp-3.0 1:3.0-0pre010526 The GNU C preprocessor.
ii gcc-3.0-base 1:3.0-0pre010526 The GNU compiler collection (base
ii libc6 2.2.3-1 GNU C Library: Shared libraries an
ii libgcc0 1:3.0-0pre010526 GCC support library.
Reply to: