RAD Studio
ContentsIndex
PreviousUpNext
Stricter C++ Compiler: String Literals Are Now Constants

String literals are now considered to be of type 'const char[]' by default. This, combined with the stricter qualification binding of const values and types, can generate error messages in code that compiled before.  

You might enable the -Vbs switch to revert string literals to non-const. However, CodeGear recommends that you update the code instead.  

Note that the change in the type of string literals can also change how the compiler resolves calls to overloaded methods. The following example illustrates this:

 void foo(char *); 
  void foo(const char *); 
  foo("string"); // New Compiler picks foo(const char *)

With C++Builder2007, the above code generates these errors:

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!