Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* 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
[parent not found: <Pine.LNX.3.91.960617181918.17165A-100000@chaos.chaos.org.uk>]
[parent not found: <Pine.SUN.3.90.960617020120.8650B-100000@ant>]
* 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

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 --
1996-06-17 16:21 string.h, strlen(), warnings from gcc David Mosberger-Tang
     [not found] <Pine.LNX.3.91.960617181918.17165A-100000@chaos.chaos.org.uk>
1996-06-17 20:51 ` Richard Henderson
     [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
  -- 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