Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Bool vs char * conversion

Programming


Tags
c++, type conversion

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-11-2017
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 21 September 2017, 4:30 PM EDT
Location: Saskatchewan, Canada
Posts: 512
Thanks: 324
Thanked 7 Times in 7 Posts
Bool vs char * conversion

I have a problem at make step to install a downloaded package consisted of different programs.

Code:
In file included from kcdbext.cc:16:0:
kcdbext.h: In member function �char* kyotocabinet::IndexDB::get(const char*, size_t, size_t*)’:
kcdbext.h:1281:14: error: cannot convert �bool’ to �char*’ in return
       return false;

1) I have tried
Code:
export LANG="en_US.UTF-8"; make

to correct the weird characters, but this seems to be a temporary fix. What is the permanent fix?
2) The error message is
Code:
kcdbext.h: In member function 'char* kyotocabinet::IndexDB::get(const char*, size_t, size_t*)':
kcdbext.h:1281:14: error: cannot convert 'bool' to 'char*' in return:
       return false;

The code fragment of the function prototype is:

Code:
char* get(const char* kbuf, size_t ksiz, size_t* sp) {
if (omode_ == 0) {
     //......
     return false;
   }

//more code ...
return rbuf;
}

I know the function is declared as char *, which is conflict with the returned value as a boolean "false". How to fix this syntax problem?
Thanks a lot!

Last edited by yifangt; 01-11-2017 at 02:54 PM.. Reason: typos
Sponsored Links
    #2  
Old Unix and Linux 01-11-2017
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 22 September 2017, 5:42 PM EDT
Location: Saskatchewan
Posts: 22,417
Thanks: 1,126
Thanked 4,237 Times in 3,917 Posts
That is very strange. 'false' really does not belong there and never did, no idea what the writer of that function was doing.

I can't tell you what the right value to return is without examining that entire function and possibly a lot more.
The Following User Says Thank You to Corona688 For This Useful Post:
yifangt (01-11-2017)
Sponsored Links
    #3  
Old Unix and Linux 01-11-2017
yifangt yifangt is offline VIP Member  
UNIX.COM VIP Member
 
Join Date: Sep 2009
Last Activity: 21 September 2017, 4:30 PM EDT
Location: Saskatchewan, Canada
Posts: 512
Thanks: 324
Thanked 7 Times in 7 Posts
Thanks!
It is a too long code to attach it here. I may need to go back to check the code again. The machine is:

Code:
Linux yt2 4.3.0-1-amd64 #1 SMP Debian 4.3.3-5 (2016-01-04) x86_64 GNU/Linux
Thread model: posix
gcc version 6.2.0 20161027 (Debian 6.2.0-10)

On another machine with smaller RAM, I only got warning but not error on it, and it went through to have all the programs compiled.

Code:
Linux HPCompaq 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

Is there any option(s) that I may have missed from the compiling part? Thanks again.
    #4  
Old Unix and Linux 01-11-2017
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 22 September 2017, 5:42 PM EDT
Location: Saskatchewan
Posts: 22,417
Thanks: 1,126
Thanked 4,237 Times in 3,917 Posts
No idea. Not enough information.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Invalid conversion from char* to char Plum Programming 1 03-29-2014 03:21 PM
Double to const char conversion emily Programming 8 02-22-2013 10:32 AM
error: invalid conversion from ‘const char*’ to ‘char*’ GSO Programming 8 06-09-2011 12:39 PM
ANSI C, char to hex conversion alikims UNIX for Dummies Questions & Answers 2 10-02-2008 10:33 AM
char to int64 conversion Raspoutine Programming 1 10-10-2005 09:35 AM



All times are GMT -4. The time now is 06:49 PM.