home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!uunet.ca!geac!r-node!druid!darcy
- From: darcy@druid.uucp (D'Arcy J.M. Cain)
- Subject: Re: HIgher problems at hand. HELP!
- Message-ID: <1992Jul29.163026.9008@druid.uucp>
- Date: Wed, 29 Jul 1992 16:30:26 GMT
- References: <1992Jul27.212311.28125@zooid.guild.org> <1992Jul28.104059.4725@druid.uucp> <1992Jul29.031820.15906@zooid.guild.org>
- Organization: D'Arcy Cain Consulting
- Lines: 40
-
- Ross Ridge <ross@zooid.guild.org> writes:
- >darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- >>Except that the whole point is to prevent any warnings with full checking
- >>turned on. Putting the define after the include would cause warnings
- >>when strstr was redefined.
- >If strstr() is declared in <string.h> then why are we redefining here?
- >Wouldn't it already be in the standard library?
-
- I have been slowly building up an entire standard library based on code
- from the net and my own additions and modifications. As part of this I
- wrote my own string.h based on the ANSI standard. Given that then I
- am in effect the implementor and there is no standard library until I
- compile it. I also use parts of the project to add ANSI functionality
- to systems that I support. I generally find I can simply replace the
- standard string.h with my own. (*) Users can then add non-existent
- functions (Usually strerror(3)). In those cases it is in the header
- but not the standard library.
-
- >>Other than changing the language itself I don't believe there is a "right"
- >>way to code strstr(3).
- >What's wrong with "return (char *)s;"?
-
- As I explained in previous posts the problem is more basic than that. The
- strstr function and others claim to return a pointer to non-const space
- whereas in reality the pointer may very well be to const char. A good
- compiler that checks that sort of thing will warn you no matter what you
- do in the function. Everything you do (including simply ignoring the
- warning message or turning them off) is just a kluge. "define const"
- is just my own kluge.
-
- BTW this isn't true in C++ where you can do:
-
- const char *strstr(const char *s, const char *wanted);
- char *strstr(char *s, const char *wanted);
-
- --
- D'Arcy J.M. Cain (darcy@druid.com) |
- D'Arcy Cain Consulting | There's no government
- Toronto, Ontario, Canada | like no government!
- +1 416 424 2871 DoD#0082 |
-