🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52955

Re: What are these strlen() warnings and how come object files are so big?

#52955
From: Marc Ullman
Date: Wed, 25 Mar 1992 18:43
55 lines
3315 bytes
> Whenever I compile anything, be it my own,
>    GNU or mit X source code, for each file that uses strlen(), I get the
>    compiler message:
>
>/usr/include/strings.h:25:
>		      warning: conflicting types for built-in function `strlen'
>
>	strlen() is declared as int in strings.h, and it makes no difference
>    whether or however I declare strlen() in code.  No other string function
>    seems to bother it.  Have I built gcc-2.0 wrong?

This type of problem can oocur because GCC 2.0 uses intrinic (builtin)
function for of a number of common clib routines.  It carries its own
protoypes for these funtions builtin as well.  The builtin prototype for
strlen is of the form:

	SIZE_TYPE strlen (const char *s)

The problem, (at least the one I had that generated this same warning
message) was that GCC 2.0 uses the machine dependent include file (e.g.
config/sparc.h) to define what size_t (SIZE_TYPE) is, and it uses a value
that in certain circumstances (like the SPARC and sun3 versions) matches what
the OS vendor (e.g. Sun) defines it as BUT VIOLATES WHAT THE ANSI-C SPEC SAYS
IT SHOULD BE.  Therefore, if you have a set of ANSI compliant header files,
you will get the type of warning messages shown above unless you redefine
the value in the config file and recompile GCC.  In the case of the SPARC
versions, the corrections are:

        a) Change PTRDIFF_TYPE from: #define PTRDIFF_TYPE "int"
                                 to: #define PTRDIFF_TYPE "long int"
        b) Change SIZE_TYPE from: #define SIZE_TYPE "int"
                              to: #define SIZE_TYPE "long unsigned int"

This way, the internal compiler definitions will match those given in
the version of stddef.h supplied with the compiler.  You may of course
have to fix up your OS supplied header files if your OS vendor is someone
like Sun who still hasn't figured out how to ship a completly ANSIfied
world yet.

In your case, since you were using the "obsolete" <strings.h> rather than
the ANSI <string.h> it sounds like you have the opposite problem.  GCC
probably has size_t correctly defined/typed to be unsigned and your
prototype in strings.h says strlen returns int.  You would be well advised
to update your code to follow the ANSI spec which means, amongst other things
using <string.h> in place of <strings.h>.  This will afford you the greatest
portability and longevity of your code.  [Make sure that your version of
string.h uses a definition of size_t that matches that given in stddef.h.]
For more information, get one of the many reference books on ANSI C.

Good luck,


--Marc Ullman
  Stanford University
Technical Details
Message-ID: <9203251843.AA10976@sun-valley.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sun-valley.stanford.edu!marc
References: <9203250308.AB00958@life.ai.mit.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,8cf0a1b64188689b
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-03-25 10:43:13 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sun-valley.stanford.edu!marc
From: marc@sun-valley.stanford.edu (Marc Ullman)
Subject: Re: What are these strlen() warnings and how come object files are so big?
Message-ID: <9203251843.AA10976@sun-valley.Stanford.EDU>
Sender: daemon@cis.ohio-state.edu
Organization: GNUs Not Usenet
References: <9203250308.AB00958@life.ai.mit.edu>
Distribution: gnu
Date: Wed, 25 Mar 1992 18:43:13 GMT
Lines: 56