LinuxQuestions.org
Visit Jeremy's Blog.
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-18-2011, 10:45 PM   #1
fsshl
Member
 
Registered: Jan 2002
Distribution: Ubuntu10.04
Posts: 49

Rep: Reputation: 1
Invalid conversion from bool


Dear Advanced c/g++ on boost programers:

I have copied and testd a simple (Copy a file with Boost) program from page 372, Example10-10, book(C++ cookbook)
but I got compile error
-----------------------------
eric_at_eric-laptop:~/cppcookbook/ch10$ g++ Example10-10.cpp
Example10-10.cpp: In function ‘int main(int, char**)’:
Example10-10.cpp:17:47: error: invalid conversion from ‘bool (*)(const std::string&)’ to ‘boost::enable_if_c<true, void>::type*’
Example10-10.cpp:17:47: error: initializing argument 2 of ‘boost::filesystem3:ath:ath(const Source&, typename
-----------------------------------------------------
// Example 10-10. Copying a file with Boost
#include <iostream>
#include <string>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>

using namespace std;
using namespace boost::filesystem;

int main(int argc, char** argv) {

// Parameter checking...

try {
// Turn the args into absolute paths using native formatting
path src = complete(path(argv[1], native));
path dst = complete(path(argv[2], native);
copy_file(src, dst);
}
catch (exception& e) {
cerr << e.what() << endl;
}

return(EXIT_SUCCESS);
}
----------------------------------------------------------------------------
I ever check around web, there is some suggestion ask me to get rid native, but in my test/system, it only
generate more errors.
my boost version probably is 1.46.1
and I am on g++ 4.5.2 and Ubuntu10.04/linuxKernel2.6.35-25
Need and thanks your help a lot in advance, Eric
 
Old 07-18-2011, 11:03 PM   #2
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Missing ")" bracket on line 17.
Code:
path src = complete(path(argv[1], native));
path dst = complete(path(argv[2], native);// <------- here
 
Old 07-18-2011, 11:13 PM   #3
fsshl
Member
 
Registered: Jan 2002
Distribution: Ubuntu10.04
Posts: 49

Original Poster
Rep: Reputation: 1
problem still

the compile error is from first
path src = complete(path(argv[1], native));
if you do not believe, please download that example code by yourself, I just tested, that download code can not compiled in my
gcc and boost
 
Old 07-19-2011, 06:42 PM   #4
SigTerm
Member
 
Registered: Dec 2009
Distribution: Slackware 12.2
Posts: 379

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by fsshl View Post
the compile error is from first
path src = complete(path(argv[1], native));
if you do not believe, please download that example code by yourself, I just tested, that download code can not compiled in my
gcc and boost
It compiles on MSVC2008 express and the only error is missing ")" bracket. Add bracket and try again.
 
  


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
invalid conversion from `int*' to `socklen_t*' r350 Programming 5 10-02-2011 05:34 PM
Invalid conversion from ‘char’ to ‘packet_t’ mcpoon Programming 4 05-25-2010 03:55 AM
Compiler error: "Conversion from 'bool' to non-scalar type 'std::string' requested" Kenny_Strawn Programming 6 03-06-2010 08:22 PM
error: invalid conversion from `void*' to `char*' pstevens57 Programming 2 03-10-2009 01:57 PM
invalid conversion from `char' to `const ch predatorz Programming 3 11-15-2008 01:00 PM

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

All times are GMT -5. The time now is 04:08 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