This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: deprecated conversion from string constant to 'char *'


Quoting Ian Lance Taylor <iant@google.com>:

Derek Atkins <warlord@MIT.EDU> writes:

typedef char* PDFFileName;
typedef const char* PDFFileNameConst;

class Foo
{
public:
  // If you change this to PDFFileNameConst then the warning goes away
  static int Blah(const PDFFileName name);
};

int do_test()
{
  return Foo::Blah("bzz");
}

This is expected behaviour. "const PDFFileName" is not "const char*", it is "char* const".

I certainly wouldn't call this "expected"..


But with the expanation I at least understand why it's happening.
I guess that means if you typedef there's no way to actually
get the "const char*", which perhaps is a bug in the language definition.

Regardless, it IS annoying.

Ian

-derek


--
      Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
      Member, MIT Student Information Processing Board  (SIPB)
      URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
      warlord@MIT.EDU                        PGP key available


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]