Edward L. Fox wrote: > Hi Tony, > > On 8/16/07, Tony Mechelynck <[EMAIL PROTECTED]> wrote: >> Chris Sutcliffe wrote: >>> Replied direct to Bram instead of the list... >>> >>> On 8/15/07, Chris Sutcliffe wrote: >>>>> Adding (char *) casts for things that are already character strings? >>>>> Isn't this a problem in gcc? >>>> GCC complains that const char*'s is being passed as a char*'s (because >>>> it's a contant string being passed in the quotes), so I re-cast it as >>>> a (char*) to get rid of the warnings. >>>> >>>> Basically because, for example, searchpath(char *) is defined to take >>>> a char* argument and "gvim.bat" is considered a constant char*, there >>>> is a mismatch in argument types (which GCC 4 is a little more adamant >>>> about, since I believe one of GCC 4's goals is to be more standards >>>> compliant). >>>> >>>> Cheers! >>>> >>>> Chris >>>> >>>> -- >>>> Chris Sutcliffe >>>> http://ir0nh34d.googlepages.com >>>> http://ir0nh34d.blogspot.com >>>> http://emergedesktop.org >>>> >>> >> shouldn't the function take const char * as arguments instead? Meaning it >> doesn't modify that argument even though it's a pointer. > > Yes, I think so. Const-correctness is always a big problem. The old > version of C without ++ doesn't support "const". So many C progammers > are not familiar with the const keyword. > > Any way, it seems that you also misunderstood the const keyword. > "const char *" means "a pointer points to const char", so you are not > able to modify the pointed content, but the pointer itself is still > modifiable. For example, you could say: > > const char *p; > ... > ++p; >
yes, yes; I mean, with a const argument you can't pass back modified pointed-to data to the calling routine, while with ordinary pointers (without const) you can. I guess I should have said the function won't modify the argument (the string) even though it is passed by address (not by value as most numeric single-item values can be passed). Best regards, Tony. -- Hartley's Second Law: Never sleep with anyone crazier than yourself. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---