[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Refreshed genx.h, plus some plans
> the problem is that it is not so. Take an ANSI C compiler, turn all warning > on and try it. okay, gcc 2.96 -ansi -pedantic -Wwrite-string with the following source: extern const char* getit(); static void munge(char* p) { p[2] = 'a'; } static void cmunge(const char* cp) { cp[2] = 'a'; } int main(int ac, char** av) { munge(getit()); munge("asdfasdf"); cmunge(getit()); } > If one declares an interface where no const is used at all, anyone can used > without casts. nope: const.cpp:7: warning: deprecated conversion from string constant to `char *' const.cpp:6: cannot convert `const char *' to `char *' for argument `1' > The only difference for API is for callbacks, function variables with 'const' > in their arguments; and nowhere else. nope: const.cpp:3: assignment of read-only location > C is good enough without 'const'. Sure. But it's better with it. /r$ -- Rich Salz Chief Security Architect DataPower Technology http://www.datapower.com XS40 XML Security Gateway http://www.datapower.com/products/xs40.html XML Security Overview http://www.datapower.com/xmldev/xmlsecurity.html
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|