OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Refreshed genx.h, plus some plans

[ Lists Home | Date Index | Thread Index ]

> 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





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS