Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Sep 2009 13:38:16 +0400
From:      Boris Samorodov <bsam@ipt.ru>
To:        freebsd-questions@FreeBSD.org
Subject:   c++: invalid conversion from 'int' to 'const char*'
Message-ID:  <53480375@bb.ipt.ru>

next in thread | raw e-mail | index | archive | help
Hello List,

I'm porting a c++ application to FreeBSD. I've got an error:
-----
~/work/src/FileChannel.cpp: In member function 'QString FileChannel::errorString()':
~/work/src/FileChannel.cpp:251: error: invalid conversion from 'int' to 'const char*'
~/work/src/FileChannel.cpp:251: error:   initializing argument 2 of 'char* strcpy(char*, const char*)'
*** Error code 1
-----

A simle patch makes the application to be compiled without errors:
-----
--- src/FileChannel.cpp.orig	2009-09-12 13:08:28.000000000 +0400
+++ src/FileChannel.cpp	2009-09-12 13:08:41.000000000 +0400
@@ -248,7 +248,7 @@
 
 QString FileChannel::errorString()
 {
-    strcpy(lastErrorString, strerror_r(errno, lastErrorString, 0));
+    strcpy(lastErrorString, "XXX: Fix me: errno should be here");
     return QString(trUtf8(lastErrorString));
 }
 
-----

If I understand correctly, an integer value which is returned by
strerror_r() should be converted to const char*.

I have _very_ basic knowledge about c++. Hence my question.
Can someone provide a patch (a proof of concept)? Thanks!

-- 
WBR, Boris Samorodov (bsam)
Research Engineer, http://www.ipt.ru Telephone & Internet SP
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53480375>