CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010
    Posts
    105

    Question warning: deprecated conversion from string constant to ‘char*’?

    I got this warning from the compiler:
    warning: deprecated conversion from string constant to ‘char*’
    when I tried to pass a string constant to a function that has a char* input argument. Something like
    myfunction("my string");
    What's the correct way to do this? Thanks!
    Last edited by acppdummy; November 14th, 2010 at 09:48 PM.

  2. #2
    Join Date
    Jan 2009
    Posts
    1,689

    Re: warning: deprecated conversion from string constant to ‘char*’?

    C89 introduced the const keyword. String literals are now considered const char *s. To preserve backwards compatibility, they allowed implicit conversion between string literals and char *, but it's deprecated. It's safe to say it will not be removed in the next standard though as there are still tons of libraries that do it.
    Last edited by ninja9578; November 14th, 2010 at 10:19 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured