Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Literal Strings as const char *?
I am a little confused. Am using DMC 8.44 (beta) which in which literal strings are taken as constant. Except when they aren't... Given the following void foo (char *); main () { char *p = "hello"; int f= 1; foo("hello"); foo(p); foo (f ? "a" : "b"); foo (f ? p : "b"); } foo (f ? "a" : "b"); ^ test.cpp(9) : Error: need explicit cast for function parameter 1 to get from: char const * to : char * foo (f ? p : "b"); ^ test.cpp(10) : Error: need explicit cast for function parameter 1 to get from: char const * to : char * --- errorlevel 1 It seems to me that the first of the function calls should be an error. Except - I guess - that this would break so much existing code as to be useless. But then if we are to allow that, then why not the tertiaries? Cheers, John. Jul 25 2005
"John Jameson" <John_member pathlink.com> wrote in message news:dc2joe$1l01$1 digitaldaemon.com...I am a little confused. Am using DMC 8.44 (beta) which in which literal Jul 29 2005
Well, I guess I should be grateful that the mighty standards committee at least decided to allow an exception for simple char *arguments :-) Anyway, am pleased to report that we have now ported all the core sections of Proteus from SC 7.5 to DM 8.44 beta with no sign of new bugs or problems so far. thanks once again for putting the -Ai switch in. Cheers, john In article <dcet0r$2srr$1 digitaldaemon.com>, Walter says..."John Jameson" <John_member pathlink.com> wrote in message news:dc2joe$1l01$1 digitaldaemon.com...I am a little confused. Am using DMC 8.44 (beta) which in which literal Aug 02 2005
|