Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* string.h, strlen(), warnings from gcc
@ 1996-06-17  1:04 David
  0 siblings, 0 replies; 6+ messages in thread
From: David @ 1996-06-17  1:04 UTC (permalink / raw)


Can anyone explain why I should need to explicitly specify extern 
strlen() after including <string.h> for the following simple example?

fresco@banshee:/tmp $ cat a.c
#include <string.h>

/*extern size_t strlen(const char *ptr);*/

size_t z(const char *y)
{
    return strlen(y);
}
fresco@banshee:/tmp $ cc a.c
a.c: In function `z':
a.c:7: warning: type mismatch in implicit declaration for built-in function `strlen'

Borris
--- 
	When working				When playing

WWW:	http://www.ant.co.uk/~borris/		http://chaos.org.uk
Email:	borris@ant.co.uk			borris@chaos.org.uk

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: string.h, strlen(), warnings from gcc
       [not found] <Pine.SUN.3.90.960617020120.8650B-100000@ant>
@ 1996-06-17  3:28 ` Richard Henderson
  1996-06-17 17:22   ` David Fell
  1996-06-17 10:04 ` Harald Koenig
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Henderson @ 1996-06-17  3:28 UTC (permalink / raw)


> Can anyone explain why I should need to explicitly specify extern 
> strlen() after including <string.h> for the following simple example?

The only ones that come to mind are:

  - your string.h is (really) old and buggy
  - your string.h has been corrupted.

What distribution are you using?  Does strlen's declaration 
actually appear in your string.h?

r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: string.h, strlen(), warnings from gcc
       [not found] <Pine.SUN.3.90.960617020120.8650B-100000@ant>
  1996-06-17  3:28 ` string.h, strlen(), warnings from gcc Richard Henderson
@ 1996-06-17 10:04 ` Harald Koenig
  1 sibling, 0 replies; 6+ messages in thread
From: Harald Koenig @ 1996-06-17 10:04 UTC (permalink / raw)


> Can anyone explain why I should need to explicitly specify extern 
> strlen() after including <string.h> for the following simple example?
> 
> fresco@banshee:/tmp $ cat a.c
> #include <string.h>
> 
> /*extern size_t strlen(const char *ptr);*/
> 
> size_t z(const char *y)
> {
>     return strlen(y);
> }
> fresco@banshee:/tmp $ cc a.c
> a.c: In function `z':
> a.c:7: warning: type mismatch in implicit declaration for built-in function `strlen'

for such problems I usually check the preprocessor output if/where
the prototype is declared and which include files are really included:

	cc -E a.c | more

looking for "strlen" and/or filenames of include files...

Harald

-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: string.h, strlen(), warnings from gcc
@ 1996-06-17 16:21 David Mosberger-Tang
  0 siblings, 0 replies; 6+ messages in thread
From: David Mosberger-Tang @ 1996-06-17 16:21 UTC (permalink / raw)


>>>>> On Mon, 17 Jun 1996 12:04:10 +0200 (MET DST), koenig@tat.physik.uni-tuebingen.de (Harald Koenig) said:

  >> Can anyone explain why I should need to explicitly specify extern
  >> strlen() after including <string.h> for the following simple
  >> example?
  >> 
  >> fresco@banshee:/tmp $ cat a.c #include <string.h>
  >> 
  >> /*extern size_t strlen(const char *ptr);*/
  >> 
  >> size_t z(const char *y) { return strlen(y); } fresco@banshee:/tmp
  >> $ cc a.c a.c: In function `z': a.c:7: warning: type mismatch in
  >> implicit declaration for built-in function `strlen'

  Harald> for such problems I usually check the preprocessor output
  Harald> if/where the prototype is declared and which include files
  Harald> are really included:

  Harald> 	cc -E a.c | more

  Harald> looking for "strlen" and/or filenames of include files...

An extra cent: gcc -g3 -E a.c is very handy, since it'll show all the
#defines etc. as well.

	--david

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: string.h, strlen(), warnings from gcc
  1996-06-17  3:28 ` string.h, strlen(), warnings from gcc Richard Henderson
@ 1996-06-17 17:22   ` David Fell
  0 siblings, 0 replies; 6+ messages in thread
From: David Fell @ 1996-06-17 17:22 UTC (permalink / raw)


On Sun, 16 Jun 1996, Richard Henderson wrote:

> > Can anyone explain why I should need to explicitly specify extern 
> > strlen() after including <string.h> for the following simple example?
> 
> The only ones that come to mind are:
> 
>   - your string.h is (really) old and buggy
>   - your string.h has been corrupted.
> 
> What distribution are you using?  Does strlen's declaration 
> actually appear in your string.h?

I'm using the Craftwork 2.1 AXP distribution. <string.h> has a conditional
like

#ifndef __GNUC__
extern ...
#endif

Redhat 3.0.3 on i386 on my home box doesn't have this conditional stuff around
these definitions. But this doesn't automatically make my AXP headers wrong.
Is this an area of gcc header files that has changed over the years?

Regards,

Borris

mailto:borris@chaos.org.uk
http://chaos.org.uk/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: string.h, strlen(), warnings from gcc
       [not found] <Pine.LNX.3.91.960617181918.17165A-100000@chaos.chaos.org.uk>
@ 1996-06-17 20:51 ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 1996-06-17 20:51 UTC (permalink / raw)


> I'm using the Craftwork 2.1 AXP distribution. <string.h> has a conditional
> like
> 
> #ifndef __GNUC__
> extern ...
> #endif

This is wrong.

You can do one of two things:

 - Try out the ECOFF version of glibc that was announced here.  It has
   been, as far as the things I've tried to compile with it, very stable.
   If you do this, you'll likely want to join the axplinux-libc mailing list.

 - Grab the libcaxp-0.43 stuff from Red Hat.  

r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1996-06-17 20:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.SUN.3.90.960617020120.8650B-100000@ant>
1996-06-17  3:28 ` string.h, strlen(), warnings from gcc Richard Henderson
1996-06-17 17:22   ` David Fell
1996-06-17 10:04 ` Harald Koenig
     [not found] <Pine.LNX.3.91.960617181918.17165A-100000@chaos.chaos.org.uk>
1996-06-17 20:51 ` Richard Henderson
1996-06-17 16:21 David Mosberger-Tang
  -- strict thread matches above, loose matches on Subject: below --
1996-06-17  1:04 David

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox