LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-03-2010, 10:28 AM   #1
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Rep: Reputation: 43
deprecated conversion from string constant to ‘char*’


Hi all,
I've just updated my linux system (Debian) and went to compile some code I'm working on. However it causes some problems, presumable because of GCC up dates. I get many of my subject line errors for example

../../common/Version_Control.cpp: In function ‘int VersionControl()’:
../../common/Version_Control.cpp:55: warning: deprecated conversion from string constant to ‘char*’

So I check up the error and it comes from my error handler code which is a function

extern void SetError(char *string,int error_number)

The net tells me all I need to do is convert char *string to const char *string, however when I do so and recompile I get the following error

Error_Control.cpp: In function ‘void SetError(const char*, int)’:
Error_Control.cpp:41: error: invalid conversion from ‘const char*’ to ‘char*’
make: *** [Error_Control.o] Error 1

So I think I've done exactly what's recommended ? Can anyone advise?
Thanks
 
Old 07-03-2010, 11:08 AM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
Can you post a code sample that replicates the problem as it's hard to see what might be causing this from your post.
 
Old 07-03-2010, 02:20 PM   #3
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Original Poster
Rep: Reputation: 43
Hi yep,
the code for the function call is

SetError("Device firmware change",1);

and the seterror function is

( did use SetError(char *string,int error_number) which caused the deprecated error so changed to)

void SetError(const char *string,int error_number)
{
ERROR_TYPE *ep;
ep=&ErrorHandler;

ep->error_flag=1;
ep->devcice_error=string;

my structure for the device error is (I don't think it has anything to do with this)

typedef struct error_type
{
int error_flag;
int error_number;
int error_data;
int error_suplementry;
char *device_error;

int io_board_started;

int secondary_device_start;
}ERROR_TYPE;

Last edited by knobby67; 07-03-2010 at 02:24 PM.
 
Old 07-03-2010, 02:29 PM   #4
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Original Poster
Rep: Reputation: 43
SOLVED sorry it was the line pointing to the structure and char *device_error; which I hadn't changed to const. I thought it was the function call! Feeling stupid.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help fixing C++ invalid conversion from const char* to char primerib Programming 26 03-10-2010 06:56 PM
invalid conversion from `const char*' to `char' error holystinken Programming 7 11-23-2009 06:01 PM
error: invalid conversion from const char* to char* Dahakon Programming 1 08-31-2009 09:33 AM
How can I disable the deprecated conversion from string constant to ‘char*’ warning? CelticBlues Programming 4 08-18-2008 12:43 PM
If I get invalid conversion from `const char*' to `char' what should I be lookin for? RHLinuxGUY Programming 5 03-12-2006 10:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration