Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!elroy.jpl.nasa.gov!ames!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: char *'s and const char *'s Message-ID: <14825@smoke.brl.mil> Date: 11 Jan 91 23:07:27 GMT References: <1991Jan11.182945.5437@nntp-server.caltech.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 12 In article <1991Jan11.182945.5437@nntp-server.caltech.edu> bruce@seismo.gps.caltech.edu (Bruce Worden) writes: >Given: >int foo(char *file); >And knowing that foo() really only needs a const char *, it is often called as: > a = foo("myfile"); >but a kindly compiler will warn something like: > junk.c:7: warning: argument passing of non-const * pointer from const * You should have declared foo as int foo(const char *file). No diagnostic should be generated when a pointer to non-const char is passed as an argument to the function, and of course no diagnostic would be issued for a pointer to const char either.