RAD Studio |  |

Stricter C++ Compiler: String Literals Are Now Constants
See Also
Collapse All

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:

Copy Code

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

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

See Also

Binding of References and Qualifiers

Template Changes

Function Overload Resolution

Initialization and Conversion

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