warning: deprecated conversion from string constant to char*

This is a discussion on warning: deprecated conversion from string constant to char* within the C++ Programming forums, part of the General Programming Boards category; Right now I'm programming a game in C++/Qt, I'm getting a warning that I don't undertstand. Below is the error ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    27

    warning: deprecated conversion from string constant to char*

    Right now I'm programming a game in C++/Qt, I'm getting a warning that I don't undertstand. Below is the error I'm getting

    Ghost.cpp:62: warning: deprecated conversion from string constant to 'char*'

    I'm getting a string of these warning messages.
    at line 62 I have the below code.

    char *ghostEyesDown2 = "eyesDown2.png";

    The program compiles however I would like to remove this error but I have no idea what's wrong with this statement. If anybody could help it would be appreciated.

  2. #2
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    "eyesDown2.png" is a (const char*), while you are trying to copy it into a non-const char*.
    You either have to make ghostEyesDown2 const, use strcpy, or use a C++ style string.
    Programming Your Mom. http://www.dandongs.com/

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,172
    So,
    const char* ghostEyesDown2 = "eyesDown2.png";

    Will get rid of that warning.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21