This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dumb C question..


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]