Show: Object Pascal C++
Display Preferences

Stricter C++ Compiler - String Literals Are Now Constants

From Appmethod Topics
Jump to: navigation, search

Go Up to Stricter C++ Compiler (Appmethod C++) Index

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, Embarcadero 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 *)


See Also

Personal tools
In other languages