This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Dumb C question..
- From: Rutger Hofman <rutger at cs dot vu dot nl>
- To: eCos Disuss <ecos-discuss at ecos dot sourceware dot org>
- Date: Wed, 24 Dec 2008 02:33:44 +0100
- Subject: Re: [ECOS] Dumb C question..
- References: <20081224001243.GF28867@lunn.ch>
Andrew Lunn wrote:
Hi Folks
Can anybody figure out what the compiler does not like:
/home/lunn/eCos/anoncvs-clean/packages/language/c/libc/string/current/tests/memchr.c: In function 'main':
/home/lunn/eCos/anoncvs-clean/packages/language/c/libc/string/current/tests/memchr.c:103: warning: assignment discards qualifiers from pointer target type
The formal and actual argument differ in constness. What happens if you
replace
(void *)"",
with
(const void *)"",
And what happens if you leave out the cast? String literals are of type
char *, but I seem to remember that they can be used in places where a
const char * is required. (The obviously correct way to handle this
would be to make string literals of type const char *, but it is
reported that that would break existing code.)
Many of the arguments to calls to memchr are adorned with casts. Are
they all really necessary?
Rutger
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss